- 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/MXF.pm
r24107 r34921 37 37 use vars qw($VERSION); 38 38 use Image::ExifTool qw(:DataAccess :Utils); 39 40 $VERSION = '1.02'; 39 use Image::ExifTool::GPS; 40 41 $VERSION = '1.08'; 41 42 42 43 sub ProcessPrimer($$$); … … 58 59 Lat => 1, Timestamp => 1, 59 60 Length => 1, UID => 1, 60 61 61 ); 62 62 … … 79 79 my %geoLat = ( 80 80 Groups => { 2 => 'Location' }, 81 PrintConv => ' require Image::ExifTool::GPS;Image::ExifTool::GPS::ToDMS($self, $val, 1, "N")',81 PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "N")', 82 82 ); 83 83 my %geoLon = ( 84 84 Groups => { 2 => 'Location' }, 85 PrintConv => ' require Image::ExifTool::GPS;Image::ExifTool::GPS::ToDMS($self, $val, 1, "E")',85 PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "E")', 86 86 ); 87 87 my %geoLatLon = ( 88 88 Groups => { 2 => 'Location' }, 89 89 PrintConv => q{ 90 require Image::ExifTool::GPS;91 90 my ($lat, $lon) = split ' ', $val; 92 91 $lat = Image::ExifTool::GPS::ToDMS($self, $lat, 1, 'N'); … … 118 117 %Image::ExifTool::MXF::Main = ( 119 118 GROUPS => { 2 => 'Video' }, 120 PROCESS_PROC => 0, # set this to zero to omit tags from lookup (way too many!) 121 VARS => { NO_ID => 1 }, # tag ID's are too bulky for documentation 119 VARS => { NO_LOOKUP => 1, NO_ID => 1 }, # tag ID's are too bulky 122 120 NOTES => q{ 123 121 Tags extracted from Material Exchange Format files. Tag ID's are not listed … … 268 266 # '060e2b34.0101.0101.02080000.00000000' => { Name => 'Security', Type => 'Node' }, 269 267 # '060e2b34.0101.0101.02080100.00000000' => { Name => 'SystemAccess', Type => 'Node' }, 270 '060e2b34.0101.0101.02080101.00000000' => { Name => 'User name', Format => 'string' },271 '060e2b34.0101.0101.02080101.01000000' => { Name => 'User name', Type => 'UTF-16' },268 '060e2b34.0101.0101.02080101.00000000' => { Name => 'UserName', Format => 'string' }, 269 '060e2b34.0101.0101.02080101.01000000' => { Name => 'UserName', Type => 'UTF-16' }, 272 270 '060e2b34.0101.0101.02080102.00000000' => { Name => 'Password', Format => 'string' }, 273 271 '060e2b34.0101.0101.02080102.01000000' => { Name => 'Password', Type => 'UTF-16' }, … … 456 454 '060e2b34.0101.0101.04010502.02000000' => { Name => 'ImageWidth', Format => 'int32u' }, # (renamed from StoredWidth) 457 455 # '060e2b34.0101.0101.04010503.00000000' => { Name => 'DigitalQuantizationAndLevelParameters', Type => 'Node' }, 458 '060e2b34.0101.0101.04010503.01000000' => { Name => 'Bits perPixel', Format => 'int8u' },456 '060e2b34.0101.0101.04010503.01000000' => { Name => 'BitsPerPixel', Format => 'int8u' }, 459 457 '060e2b34.0101.0101.04010503.02000000' => { Name => 'RoundingMethodCode', Format => 'string' }, 460 458 '060e2b34.0101.0101.04010503.03000000' => { Name => 'BlackReferenceLevel', Format => 'int32u' }, … … 785 783 '060e2b34.0101.0101.07012001.10030100' => { Name => 'TelephoneNumber', Format => 'string' }, 786 784 '060e2b34.0101.0101.07012001.10030200' => { Name => 'FaxNumber', Format => 'string' }, 787 '060e2b34.0101.0101.07012001.10030300' => { Name => 'E- MailAddress', Format => 'string' },785 '060e2b34.0101.0101.07012001.10030300' => { Name => 'E-mailAddress', Format => 'string' }, 788 786 # '060e2b34.0101.0101.07012002.00000000' => { Name => 'PlaceDescriptions', Type => 'Node' }, 789 787 '060e2b34.0101.0101.07012002.01000000' => { Name => 'SettingDescription', Format => 'string' }, … … 808 806 '060e2b34.0101.0101.07020102.04010000' => { Name => 'TimecodeEndDateTime', Type => 'UILSBF', Unknown => 1, Groups => { 2 => 'Time' } }, 809 807 # '060e2b34.0101.0101.07020102.05000000' => { Name => 'MaterialOccurrenceTrueDateTime', Type => 'Node' }, 810 '060e2b34.0101.0101.07020102.05010000' => { Name => 'UTCLastModifyDate', Format => 'string' },811 '060e2b34.0101.0101.07020102.05020000' => { Name => 'LocalLastModifyDate', Format => 'string' },808 '060e2b34.0101.0101.07020102.05010000' => { Name => 'UTCLastModifyDate', Format => 'string', Groups => { 2 => 'Time' } }, 809 '060e2b34.0101.0101.07020102.05020000' => { Name => 'LocalLastModifyDate', Format => 'string', Groups => { 2 => 'Time' } }, 812 810 # '060e2b34.0101.0101.07020102.06000000' => { Name => 'MaterialOccurrenceTimeAddress', Type => 'Node' }, 813 811 '060e2b34.0101.0101.07020102.06010000' => { Name => 'TimecodeLastModifyDate', Type => 'UILSBF', Unknown => 1, Groups => { 2 => 'Time' } }, … … 845 843 '060e2b34.0101.0101.07020110.01020000' => { Name => 'TimecodeCreationDateTime', Type => 'UILSBF', Unknown => 1, Groups => { 2 => 'Time' } }, 846 844 # '060e2b34.0101.0101.07020110.02000000' => { Name => 'ModifyDate', Type => 'Node' }, 847 '060e2b34.0101.0101.07020110.02010000' => { Name => 'LocalModifyDate', Format => 'string' },845 '060e2b34.0101.0101.07020110.02010000' => { Name => 'LocalModifyDate', Format => 'string', Groups => { 2 => 'Time' } }, 848 846 '060e2b34.0101.0101.07020110.02020000' => { Name => 'TimecodeModifyDate', Type => 'UILSBF', Unknown => 1, Groups => { 2 => 'Time' } }, 849 847 # '060e2b34.0101.0101.07020200.00000000' => { Name => 'Durations', Type => 'Node' }, … … 1062 1060 '060e2b34.0101.0102.04010401.01000000' => { Name => 'AnalogVideoSystemName', Type => 'VideoSignalType', Unknown => 1 }, 1063 1061 '060e2b34.0101.0102.04010501.10000000' => { Name => 'VerticalSub-sampling', Format => 'int32u' }, 1064 '060e2b34.0101.0102.04010503.01010000' => { Name => 'Bits perPixel', Format => 'int32u' },1062 '060e2b34.0101.0102.04010503.01010000' => { Name => 'BitsPerPixel', Format => 'int32u' }, 1065 1063 '060e2b34.0101.0102.04010503.05000000' => { Name => 'ColorRangeLevels', Format => 'int32u' }, 1066 1064 '060e2b34.0101.0102.04010503.06000000' => { Name => 'PixelLayout', Type => 'RGBALayout', Unknown => 1 }, … … 1357 1355 '060e2b34.0101.0103.02080203.00000000' => { Name => 'ClassifiedBy', Format => 'string' }, 1358 1356 '060e2b34.0101.0103.02080204.00000000' => { Name => 'ClassificationReason', Format => 'string' }, 1359 '060e2b34.0101.0103.02080205.00000000' => { Name => 'DeclassificationDate', Format => 'string' },1357 '060e2b34.0101.0103.02080205.00000000' => { Name => 'DeclassificationDate', Format => 'string', Groups => { 2 => 'Time' } }, 1360 1358 '060e2b34.0101.0103.02080206.00000000' => { Name => 'DerivedFrom', Format => 'string' }, 1361 1359 '060e2b34.0101.0103.02080207.00000000' => { Name => 'ClassificationComment', Format => 'string' }, … … 1367 1365 '060e2b34.0101.0103.02300101.01000000' => { Name => 'NatureOfPersonality', Type => 'UTF-16' }, 1368 1366 '060e2b34.0101.0103.02300102.01010000' => { Name => 'ContributionStatus', Type => 'UTF-16' }, 1369 '060e2b34.0101.0103.02300103.01010000' => { Name => 'Support orAdministrationStatus', Type => 'UTF-16' },1367 '060e2b34.0101.0103.02300103.01010000' => { Name => 'SupportOrAdministrationStatus', Type => 'UTF-16' }, 1370 1368 '060e2b34.0101.0103.02300201.01000000' => { Name => 'OrganizationKind', Type => 'UTF-16' }, 1371 1369 '060e2b34.0101.0103.02300202.01010000' => { Name => 'ProductionOrganizationRole', Type => 'UTF-16' }, … … 1525 1523 '060e2b34.0101.0103.07012001.10030101' => { Name => 'TelephoneNumber', Type => 'UTF-16' }, 1526 1524 '060e2b34.0101.0103.07012001.10030201' => { Name => 'FaxNumber', Type => 'UTF-16' }, 1527 '060e2b34.0101.0103.07012001.10030301' => { Name => 'E- MailAddress', Type => 'UTF-16' },1525 '060e2b34.0101.0103.07012001.10030301' => { Name => 'E-mailAddress', Type => 'UTF-16' }, 1528 1526 '060e2b34.0101.0103.07012002.01010000' => { Name => 'SettingDescription', Type => 'UTF-16' }, 1529 1527 '060e2b34.0101.0103.07020101.01050000' => { Name => 'POSIXMicroseconds', Format => 'int64u' }, … … 2418 2416 ); 2419 2417 2420 # header information 2418 # header information 2421 2419 %Image::ExifTool::MXF::Header = ( 2422 2420 GROUPS => { 2 => 'Video' }, … … 2479 2477 sub ReadMXFValue($$$) 2480 2478 { 2481 my ($e xifTool, $val, $type) = @_;2479 my ($et, $val, $type) = @_; 2482 2480 my $len = length($val); 2483 2481 local $_; 2484 2482 2485 2483 if ($type eq 'UTF-16') { 2486 $val = $e xifTool->Decode($val, 'UCS2'); # (until we handle UTF-16 properly)2484 $val = $et->Decode($val, 'UCS2'); # (until we handle UTF-16 properly) 2487 2485 } elsif ($type eq 'ProductVersion') { 2488 2486 my @a = unpack('n*', $val); … … 2528 2526 my ($count, $size) = unpack('NN', $val); 2529 2527 # validate data length 2530 $len == 8 + $count * $size or $e xifTool->WarnOnce("Bad array or batch size");2528 $len == 8 + $count * $size or $et->WarnOnce("Bad array or batch size"); 2531 2529 my ($i, @a); 2532 2530 for ($i=0; $i<$count; ++$i) { … … 2538 2536 $_ = join('-', unpack('H8H4H4H4H12', $_)) foreach @a; 2539 2537 } elsif ($type eq 'BatchOfUL' or $type =~ /^WeakReference/) { 2540 $_ = ReadMXFValue($e xifTool, $_, 'UL') foreach @a;2538 $_ = ReadMXFValue($et, $_, 'UL') foreach @a; 2541 2539 } 2542 2540 $val = \@a; … … 2571 2569 sub ProcessPrimer($$$) 2572 2570 { 2573 my ($e xifTool, $dirInfo, $tagTablePtr) = @_;2571 my ($et, $dirInfo, $tagTablePtr) = @_; 2574 2572 my $dataPt = $$dirInfo{DataPt}; 2575 2573 my $end = $$dirInfo{DirLen}; … … 2578 2576 my $size = Get32u($dataPt, 4); 2579 2577 return 0 unless $size >= 18; 2580 $e xifTool->VerboseDir('MXF Primer', $count);2581 my $verbose = $e xifTool->Options('Verbose');2582 my $primer = $$e xifTool{MXFInfo}{Primer};2578 $et->VerboseDir('MXF Primer', $count); 2579 my $verbose = $et->Options('Verbose'); 2580 my $primer = $$et{MXFInfo}{Primer}; 2583 2581 my $pos = 8; 2584 2582 my $i; … … 2594 2592 my $indx = $i . ')'; 2595 2593 $indx .= ' ' if length($indx) < 3; 2596 $e xifTool->VPrint(0, sprintf(" | $indx 0x%.4x => '$global'\n", $local));2594 $et->VPrint(0, sprintf(" | $indx 0x%.4x => '${global}'\n", $local)); 2597 2595 } 2598 2596 return 1; … … 2605 2603 sub ProcessLocalSet($$$) 2606 2604 { 2607 my ($e xifTool, $dirInfo, $tagTablePtr) = @_;2605 my ($et, $dirInfo, $tagTablePtr) = @_; 2608 2606 local $_; 2609 2607 my $dataPt = $$dirInfo{DataPt}; 2610 2608 my $dataPos = $$dirInfo{DataPos}; 2611 2609 my $end = $$dirInfo{DirLen}; 2612 my $mxfInfo = $$e xifTool{MXFInfo};2610 my $mxfInfo = $$et{MXFInfo}; 2613 2611 my $primer = $$mxfInfo{Primer}; 2614 2612 my (@strongRef, @groups, $instance, $editRate, $trackID, $langCode, $textLang); 2615 2613 2616 $e xifTool->VerboseDir('MXF LocalSet', undef, $end);2614 $et->VerboseDir('MXF LocalSet', undef, $end); 2617 2615 2618 2616 # loop through all tags in this local set … … 2629 2627 } else { 2630 2628 $tag = $loc; 2631 # $e xifTool->WarnOnce('Missing local key for at least one tag');2629 # $et->WarnOnce('Missing local key for at least one tag'); 2632 2630 $extra = ', NOT IN PRIMER!'; 2633 2631 } … … 2637 2635 $type = $$tagInfo{Type}; 2638 2636 if ($type and $knownType{$type}) { 2639 $val = ReadMXFValue($e xifTool, substr($$dataPt, $pos, $len), $type);2637 $val = ReadMXFValue($et, substr($$dataPt, $pos, $len), $type); 2640 2638 push @strongRef, (ref $val ? @$val : $val) if $type =~ /^StrongReference/; 2641 2639 # remember instance UID of this local set … … 2651 2649 } 2652 2650 # get tagInfo ref the standard way to handle Unknown tags 2653 $tagInfo = $langInfo || $e xifTool->GetTagInfo($tagTablePtr, $tag);2651 $tagInfo = $langInfo || $et->GetTagInfo($tagTablePtr, $tag); 2654 2652 # set Binary flag to extract all unknown-format tags as Binary data 2655 2653 if ($tagInfo and $$tagInfo{Unknown} and not defined $$tagInfo{Binary}) { 2656 2654 $$tagInfo{Binary} = not ($$tagInfo{Format} or ($type and $knownType{$type})); 2657 2655 } 2658 my $key = $e xifTool->HandleTag($tagTablePtr, $tag, $val,2656 my $key = $et->HandleTag($tagTablePtr, $tag, $val, 2659 2657 Extra => $extra, 2660 2658 TagInfo => $tagInfo, … … 2670 2668 # (necessary because we don't have all the information we need 2671 2669 # to do this on the fly when the file is parsed linearly) 2672 push @groups, $$e xifTool{TAG_EXTRA}{$key};2670 push @groups, $$et{TAG_EXTRA}{$key}; 2673 2671 next unless $tagInfo; 2674 2672 my $name = $$tagInfo{Name}; … … 2676 2674 $$mxfInfo{FixDuration}{$key} = 1; 2677 2675 } elsif ($$tagInfo{LanguageCode}) { 2678 $langCode = $$e xifTool{VALUE}{$key};2676 $langCode = $$et{VALUE}{$key}; 2679 2677 } elsif ($name eq 'EditRate') { 2680 $editRate = $$e xifTool{VALUE}{$key};2678 $editRate = $$et{VALUE}{$key}; 2681 2679 } elsif ($name =~ /TrackID$/) { 2682 $trackID = $$e xifTool{VALUE}{$key};2680 $trackID = $$et{VALUE}{$key}; 2683 2681 unless ($$mxfInfo{Group1}{$trackID}) { 2684 2682 # save lookup to convert TrackID to our group 1 name … … 2702 2700 # save instance UID's in groups hash (used to remove duplicates later) 2703 2701 $$_{UID} = $instance foreach @groups; 2704 $$objInfo{Name} = $$e xifTool{DIR_NAME};2702 $$objInfo{Name} = $$et{DIR_NAME}; 2705 2703 $$objInfo{TrackID} = $trackID if defined $trackID; 2706 2704 $$objInfo{EditRate} = $editRate if $editRate; … … 2720 2718 } 2721 2719 # save instance UID's of Preface's 2722 push @{$$mxfInfo{Preface}}, $instance if $$e xifTool{DIR_NAME} eq 'Preface';2720 push @{$$mxfInfo{Preface}}, $instance if $$et{DIR_NAME} eq 'Preface'; 2723 2721 } 2724 2722 return 1; … … 2785 2783 sub ConvertDurations($$) 2786 2784 { 2787 my ($e xifTool, $mxfInfo) = @_;2788 my $valueHash = $$e xifTool{VALUE};2789 my $infoHash = $$e xifTool{TAG_INFO};2790 my $tagExtra = $$e xifTool{TAG_EXTRA};2785 my ($et, $mxfInfo) = @_; 2786 my $valueHash = $$et{VALUE}; 2787 my $infoHash = $$et{TAG_INFO}; 2788 my $tagExtra = $$et{TAG_EXTRA}; 2791 2789 my $editHash = $$mxfInfo{EditRate}; 2792 2790 my ($tag, $key, $i); … … 2809 2807 sub ProcessMXF($$) 2810 2808 { 2811 my ($e xifTool, $dirInfo) = @_;2809 my ($et, $dirInfo) = @_; 2812 2810 my $raf = $$dirInfo{RAF}; 2813 my $verbose = $e xifTool->Options('Verbose');2814 my $unknown = $e xifTool->Options('Unknown');2811 my $verbose = $et->Options('Verbose'); 2812 my $unknown = $et->Options('Unknown'); 2815 2813 my ($buff, $preface, $n, $headerEnd, $footerPos); 2816 2814 … … 2820 2818 my $start = pos($buff) - 11; 2821 2819 2822 $e xifTool->SetFileType();2820 $et->SetFileType(); 2823 2821 SetByteOrder('MM'); 2824 $raf->Seek($start, 0) or $e xifTool->Warn('Seek error'), return 1;2822 $raf->Seek($start, 0) or $et->Warn('Seek error'), return 1; 2825 2823 my $tagTablePtr = GetTagTable('Image::ExifTool::MXF::Main'); 2826 2824 … … 2835 2833 Preface => [ ], # instance UID's for all Preface objects 2836 2834 ); 2837 $$e xifTool{MXFInfo} = \%mxfInfo;2835 $$et{MXFInfo} = \%mxfInfo; 2838 2836 2839 2837 # set group 1 name for all tags (so we can overwrite with track number later) 2840 $$e xifTool{SET_GROUP1} = 'MXF';2838 $$et{SET_GROUP1} = 'MXF'; 2841 2839 2842 2840 for (;;) { … … 2849 2847 # skip directly to footer if possible 2850 2848 if ($footerPos and $footerPos > $pos and (not $verbose or not $unknown)) { 2851 $e xifTool->VPrint(0, "[Skipping to footer. Use Unknown option to parse body partitions]\n");2849 $et->VPrint(0, "[Skipping to footer. Use Unknown option to parse body partitions]\n"); 2852 2850 $raf->Seek($footerPos, 0) or last; 2853 2851 $pos = $footerPos; … … 2878 2876 my $name = $1 eq '0d' ? 'UserOrganizationPublicUse' : 'Experimental'; 2879 2877 $tagInfo = { Name => $name, %localSet }; 2880 Image::ExifTool::AddTagToTable($tagTablePtr, $ul, $tagInfo);2878 AddTagToTable($tagTablePtr, $ul, $tagInfo); 2881 2879 } 2882 2880 my ($val, $dataPt); … … 2895 2893 $dataPt = \$buff; 2896 2894 my $type = $$tagInfo{Type}; 2897 $val = ReadMXFValue($e xifTool, $buff, $type) if $type and $knownType{$type};2895 $val = ReadMXFValue($et, $buff, $type) if $type and $knownType{$type}; 2898 2896 } elsif (($tagInfo and (not $$tagInfo{Unknown} or $unknown)) or $verbose) { 2899 2897 if ($tagInfo) { … … 2922 2920 next; 2923 2921 } 2924 $e xifTool->HandleTag($tagTablePtr, $ul, $val,2922 $et->HandleTag($tagTablePtr, $ul, $val, 2925 2923 TagInfo => $tagInfo, 2926 2924 DataPt => $dataPt, … … 2932 2930 # walk entire MXF object tree to fix family 1 group names 2933 2931 my ($pathInfo, $tag, %did, %bestDur); 2934 $pathInfo = { Path => [ 'MXF' ] } if $e xifTool->Options('SavePath');2932 $pathInfo = { Path => [ 'MXF' ] } if $et->Options('SavePath'); 2935 2933 foreach $preface (@{$mxfInfo{Preface}}) { 2936 2934 SetGroups(\%mxfInfo, $preface, $pathInfo); 2937 2935 } 2938 2936 # convert Duration values to seconds based on the appropriate EditRate 2939 ConvertDurations($e xifTool, \%mxfInfo);2937 ConvertDurations($et, \%mxfInfo); 2940 2938 2941 2939 # remove tags to keep only the one from the most recent instance of the object 2942 my $tagExtra = $$e xifTool{TAG_EXTRA};2943 my $fileOrder = $$e xifTool{FILE_ORDER};2940 my $tagExtra = $$et{TAG_EXTRA}; 2941 my $fileOrder = $$et{FILE_ORDER}; 2944 2942 # also determine our best Duration value 2945 2943 if ($mxfInfo{BestDuration}) { … … 2954 2952 my $utag = "$1 $instance"; # instance-specific tag name 2955 2953 if ($did{$utag}) { 2956 Image::ExifTool::DeleteTag($e xifTool, $tag); # delete the duplicate2954 Image::ExifTool::DeleteTag($et, $tag); # delete the duplicate 2957 2955 } else { 2958 2956 $did{$utag} = 1; 2959 2957 if ($bestDur{$utag}) { 2960 2958 # save best duration value 2961 my $val = $$e xifTool{VALUE}{$tag};2962 $e xifTool->HandleTag($tagTablePtr, '060e2b34.0101.0102.07020201.01030000', $val);2959 my $val = $$et{VALUE}{$tag}; 2960 $et->HandleTag($tagTablePtr, '060e2b34.0101.0102.07020201.01030000', $val); 2963 2961 } 2964 2962 } … … 2966 2964 2967 2965 # clean up and return 2968 delete $$e xifTool{SET_GROUP1};2969 delete $$e xifTool{MXFInfo};2966 delete $$et{SET_GROUP1}; 2967 delete $$et{MXFInfo}; 2970 2968 return 1; 2971 2969 } … … 2990 2988 =head1 AUTHOR 2991 2989 2992 Copyright 2003-20 11, Phil Harvey (phil at owl.phy.queensu.ca)2990 Copyright 2003-2021, Phil Harvey (philharvey66 at gmail.com) 2993 2991 2994 2992 This library is free software; you can redistribute it and/or modify it
Note:
See TracChangeset
for help on using the changeset viewer.