- Timestamp:
- 2011-06-01T12:33:42+12:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/cpan/Image/ExifTool/ASF.pm
r16842 r24107 7 7 # 8 8 # References: 1) http://www.microsoft.com/windows/windowsmedia/format/asfspec.aspx 9 # 2) http://www.adobe.com/devnet/xmp/pdfs/XMPSpecificationPart3.pdf (Oct 2008) 9 10 #------------------------------------------------------------------------------ 10 11 … … 15 16 use Image::ExifTool qw(:DataAccess :Utils); 16 17 use Image::ExifTool::Exif; 17 18 $VERSION = '1.05'; 18 use Image::ExifTool::RIFF; 19 20 $VERSION = '1.17'; 19 21 20 22 sub ProcessMetadata($$$); 21 23 sub ProcessContentDescription($$$); 22 sub ProcessP review($$$);24 sub ProcessPicture($$$); 23 25 sub ProcessCodecList($$$); 24 26 … … 63 65 PROCESS_PROC => \&Image::ExifTool::ASF::ProcessASF, 64 66 NOTES => q{ 65 ASF format is used by Windows WMA and WMV files. Tag ID's aren't listed66 because they are huge 128-bit GUID's that would ruin the formatting of this67 table.67 The ASF format is used by Windows WMA and WMV files, and DIVX videos. Tag 68 ID's aren't listed because they are huge 128-bit GUID's that would ruin the 69 formatting of this table. 68 70 }, 69 71 '75B22630-668E-11CF-A6D9-00AA0062CE6C' => { … … 76 78 'FEB103F8-12AD-4C64-840F-2A1D2F7AD48C' => 'MediaIndex', 77 79 '3CB73FD0-0C4A-4803-953D-EDF7B6228F0C' => 'TimecodeIndex', 80 'BE7ACFCB-97A9-42E8-9C71-999491E3AFAC' => { #2 81 Name => 'XMP', 82 SubDirectory => { TagTable => 'Image::ExifTool::XMP::Main' }, 83 }, 78 84 ); 79 85 … … 158 164 BannerImageType => {}, 159 165 BannerImageURL => {}, 160 Bitrate => { },166 Bitrate => { PrintConv => 'ConvertBitrate($val)' }, 161 167 Broadcast => {}, 162 168 BufferAverage => {}, … … 165 171 Copyright => { Groups => { 2 => 'Author' } }, 166 172 CopyrightURL => { Groups => { 2 => 'Author' } }, 167 CurrentBitrate => { },173 CurrentBitrate => { PrintConv => 'ConvertBitrate($val)' }, 168 174 Description => {}, 169 175 DRM_ContentID => {}, … … 183 189 DRM_LicenseAcqURL => {}, 184 190 DRM_V1LicenseAcqURL => {}, 185 Duration => { },191 Duration => { PrintConv => 'ConvertDuration($val)' }, 186 192 FileSize => {}, 187 193 HasArbitraryDataStream => {}, … … 201 207 NSC_Phone => {}, 202 208 NumberOfFrames => {}, 203 OptimalBitrate => { },209 OptimalBitrate => { PrintConv => 'ConvertBitrate($val)' }, 204 210 PeakValue => {}, 205 211 Rating => {}, … … 268 274 ParentalRatingReason => {}, 269 275 PartOfSet => {}, 270 PeakBitrate => { },276 PeakBitrate => { PrintConv => 'ConvertBitrate($val)' }, 271 277 Period => {}, 272 278 Picture => { 273 279 SubDirectory => { 274 TagTable => 'Image::ExifTool::ASF::P review',280 TagTable => 'Image::ExifTool::ASF::Picture', 275 281 }, 276 282 }, … … 313 319 ); 314 320 315 %Image::ExifTool::ASF::P review= (316 PROCESS_PROC => \&ProcessP review,317 GROUPS => { 2 => ' Video' },321 %Image::ExifTool::ASF::Picture = ( 322 PROCESS_PROC => \&ProcessPicture, 323 GROUPS => { 2 => 'Image' }, 318 324 0 => { 319 Name => 'P reviewType',320 PrintConv => { 321 0 => 'Other picture type',322 1 => '32x32 PNG file icon',323 2 => 'Other file icon',324 3 => 'Front album cover',325 4 => 'Back album cover',326 5 => 'Leaflet page',327 6 => 'Media label',328 7 => 'Lead artist, performer, or soloist',329 8 => 'Artist s or performers',325 Name => 'PictureType', 326 PrintConv => { # (Note: Duplicated in ID3, ASF and FLAC modules!) 327 0 => 'Other', 328 1 => '32x32 PNG Icon', 329 2 => 'Other Icon', 330 3 => 'Front Cover', 331 4 => 'Back Cover', 332 5 => 'Leaflet', 333 6 => 'Media', 334 7 => 'Lead Artist', 335 8 => 'Artist', 330 336 9 => 'Conductor', 331 10 => 'Band or orchestra',337 10 => 'Band', 332 338 11 => 'Composer', 333 12 => 'Lyricist or writer',334 13 => 'Recording studio or location',335 14 => 'Recording session',339 12 => 'Lyricist', 340 13 => 'Recording Studio or Location', 341 14 => 'Recording Session', 336 342 15 => 'Performance', 337 16 => 'Capture from movie or video',338 17 => ' A bright colored fish',343 16 => 'Capture from Movie or Video', 344 17 => 'Bright(ly) Colored Fish', 339 345 18 => 'Illustration', 340 19 => 'Band or artist logo',341 20 => 'Publisher or studio logo',346 19 => 'Band Logo', 347 20 => 'Publisher Logo', 342 348 }, 343 349 }, 344 1 => 'P reviewMimeType',345 2 => 'P reviewDescription',350 1 => 'PictureMimeType', 351 2 => 'PictureDescription', 346 352 3 => { 347 Name => 'P reviewImage',348 ValueConv => '$self->ValidateImage(\$val,$tag)',353 Name => 'Picture', 354 Binary => 1, 349 355 }, 350 356 ); … … 358 364 ValueConv => 'Image::ExifTool::ASF::GetGUID($val)', 359 365 }, 360 16 => { Name => 'File Size',Format => 'int64u' },366 16 => { Name => 'FileLength', Format => 'int64u' }, 361 367 24 => { 362 368 Name => 'CreationDate', … … 374 380 Format => 'int64u', 375 381 ValueConv => '$val / 1e7', 376 PrintConv => ' "$val sec"',382 PrintConv => 'ConvertDuration($val)', 377 383 }, 378 384 48 => { … … 380 386 Format => 'int64u', 381 387 ValueConv => '$val / 1e7', 382 PrintConv => ' "$val sec"',388 PrintConv => 'ConvertDuration($val)', 383 389 }, 384 390 56 => { Name => 'Preroll', Format => 'int64u' }, … … 386 392 68 => { Name => 'MinPacketSize',Format => 'int32u' }, 387 393 72 => { Name => 'MaxPacketSize',Format => 'int32u' }, 388 76 => { Name => 'MaxBitrate', Format => 'int32u' },394 76 => { Name => 'MaxBitrate', Format => 'int32u', PrintConv => 'ConvertBitrate($val)' }, 389 395 ); 390 396 … … 414 420 Format => 'int64u', 415 421 ValueConv => '$val / 1e7', 416 PrintConv => '"$val s ec"',422 PrintConv => '"$val s"', 417 423 }, 418 424 48 => { … … 427 433 Format => 'int16u', 428 434 PrintHex => 1, 429 # from http://www.iana.org/assignments/wave-avi-codec-registry 430 # and http://developers.videolan.org/vlc/vlc/doc/doxygen/html/codecs_8h-source.html 431 PrintConv => { 432 0x0001 => 'Microsoft PCM', 433 0x0002 => 'Microsoft ADPCM', 434 0x0003 => 'IEEE Float', 435 0x0004 => 'Cmpaq VSELP', 436 0x0005 => 'IBM CVSD', 437 0x0006 => 'Microsoft A-Law', 438 0x0007 => 'Microsoft Mu-Law', 439 0x0008 => 'DTS Coherent Acoustics 1', 440 0x0010 => 'OKI ADPCM', 441 0x0011 => 'Intel DVI ADPCM', 442 0x0012 => 'Videologic MediaSpace ADPCM', 443 0x0013 => 'Sierra ADPCM', 444 0x0014 => 'G.723 ADPCM', 445 0x0015 => 'DSP Solution DIGISTD', 446 0x0016 => 'DSP Solution DIGIFIX', 447 0x0017 => 'Dialogic OKI ADPCM', 448 0x0018 => 'MediaVision ADPCM', 449 0x0019 => 'HP CU', 450 0x0020 => 'Yamaha ADPCM', 451 0x0021 => 'Speech Compression Sonarc', 452 0x0022 => 'DSP Group True Speech', 453 0x0023 => 'Echo Speech EchoSC1', 454 0x0024 => 'Audiofile AF36', 455 0x0025 => 'APTX', 456 0x0026 => 'AudioFile AF10', 457 0x0027 => 'Prosody 1612', 458 0x0028 => 'LRC', 459 0x0030 => 'Dolby AC2', 460 0x0031 => 'GSM610', 461 0x0032 => 'MSNAudio', 462 0x0033 => 'Antex ADPCME', 463 0x0034 => 'Control Res VQLPC', 464 0x0035 => 'Digireal', 465 0x0036 => 'DigiADPCM', 466 0x0037 => 'Control Res CR10', 467 0x0038 => 'NMS VBXADPCM', 468 0x0039 => 'Roland RDAC', 469 0x003a => 'EchoSC3', 470 0x003b => 'Rockwell ADPCM', 471 0x003c => 'Rockwell Digit LK', 472 0x003d => 'Xebec', 473 0x0040 => 'Antex Electronics G.721', 474 0x0041 => 'G.728 CELP', 475 0x0042 => 'MSG723', 476 0x0045 => 'G.726 ADPCM', 477 0x0050 => 'MPEG', 478 0x0052 => 'RT24', 479 0x0053 => 'PAC', 480 0x0055 => 'MPEG Layer 3', 481 0x0059 => 'Lucent G.723', 482 0x0060 => 'Cirrus', 483 0x0061 => 'ESPCM', 484 0x0062 => 'Voxware', 485 0x0063 => 'Canopus Atrac', 486 0x0064 => 'G.726 ADPCM', 487 0x0066 => 'DSAT', 488 0x0067 => 'DSAT Display', 489 0x0069 => 'Voxware Byte Aligned', 490 0x0070 => 'Voxware AC8', 491 0x0071 => 'Voxware AC10', 492 0x0072 => 'Voxware AC16', 493 0x0073 => 'Voxware AC20', 494 0x0074 => 'Voxware MetaVoice', 495 0x0075 => 'Voxware MetaSound', 496 0x0076 => 'Voxware RT29HW', 497 0x0077 => 'Voxware VR12', 498 0x0078 => 'Voxware VR18', 499 0x0079 => 'Voxware TQ40', 500 0x0080 => 'Softsound', 501 0x0081 => 'Voxware TQ60', 502 0x0082 => 'MSRT24', 503 0x0083 => 'G.729A', 504 0x0084 => 'MVI MV12', 505 0x0085 => 'DF G.726', 506 0x0086 => 'DF GSM610', 507 0x0088 => 'ISIAudio', 508 0x0089 => 'Onlive', 509 0x0091 => 'SBC24', 510 0x0092 => 'Dolby AC3 SPDIF', 511 0x0097 => 'ZyXEL ADPCM', 512 0x0098 => 'Philips LPCBB', 513 0x0099 => 'Packed', 514 0x00FF => 'MPEG-4', 515 0x0100 => 'Rhetorex ADPCM', 516 0x0101 => 'BeCubed Software IRAT', 517 0x0111 => 'Vivo G.723', 518 0x0112 => 'Vivo Siren', 519 0x0123 => 'Digital G.723', 520 0x0160 => 'Windows Media v1', 521 0x0161 => 'Windows Media v2', 522 0x0162 => 'Windows Media 9 Professional', 523 0x0163 => 'Windows Media 9 Lossless', 524 0x0200 => 'Creative ADPCM', 525 0x0202 => 'Creative FastSpeech8', 526 0x0203 => 'Creative FastSpeech10', 527 0x0220 => 'Quarterdeck', 528 0x0300 => 'FM Towns Snd', 529 0x0400 => 'BTV Digital', 530 0x0680 => 'VME VMPCM', 531 0x1000 => 'OLIGSM', 532 0x1001 => 'OLIADPCM', 533 0x1002 => 'OLICELP', 534 0x1003 => 'OLISBC', 535 0x1004 => 'OLIOPR', 536 0x1100 => 'LH Codec', 537 0x1400 => 'Norris', 538 0x1401 => 'ISIAudio', 539 0x1500 => 'Soundspace Music Compression', 540 0x2000 => 'DVM', 541 0x2001 => 'DTS Coherent Acoustics 2', 542 0x4143 => 'MPEG-4 (Divio)', 543 }, 435 SeparateTable => 'RIFF AudioEncoding', 436 PrintConv => \%Image::ExifTool::RIFF::audioEncoding, 544 437 }, 545 438 { … … 624 517 { 625 518 my ($exifTool, $dirInfo, $tagTablePtr) = @_; 626 my $verbose = $exifTool->Options('Verbose');627 519 my $dataPt = $$dirInfo{DataPt}; 628 520 my $dirLen = $$dirInfo{DirLen}; … … 635 527 next unless $len; 636 528 return 0 if $pos + $len > $dirLen; 637 my $val = $exifTool-> Unicode2Charset(substr($$dataPt,$pos,$len),'II');529 my $val = $exifTool->Decode(substr($$dataPt,$pos,$len),'UCS2','II'); 638 530 $exifTool->HandleTag($tagTablePtr, $tag, $val); 639 531 $pos += $len; … … 649 541 { 650 542 my ($exifTool, $dirInfo, $tagTablePtr) = @_; 651 my $verbose = $exifTool->Options('Verbose');652 543 my $dataPt = $$dirInfo{DataPt}; 653 544 my $dirLen = $$dirInfo{DirLen}; … … 681 572 my @vals; 682 573 if ($format == 0) { # unicode string 683 $vals[0] = $exifTool-> Unicode2Charset(substr($$dataPt,$pos,$size),'II');574 $vals[0] = $exifTool->Decode(substr($$dataPt,$pos,$size),'UCS2','II'); 684 575 } elsif ($format == 2) { # 4-byte boolean 685 576 @vals = ReadValue($dataPt, $pos, 'int32u', undef, $size); … … 706 597 { 707 598 my ($exifTool, $dirInfo, $tagTablePtr) = @_; 708 my $verbose = $exifTool->Options('Verbose');709 599 my $dataPt = $$dirInfo{DataPt}; 710 600 my $dirLen = $$dirInfo{DirLen}; … … 719 609 $pos += 2; 720 610 return 0 if $pos + $nameLen + 4 > $dirLen; 721 my $tag = Image::ExifTool:: Unicode2Latin(substr($$dataPt,$pos,$nameLen),'v');611 my $tag = Image::ExifTool::Decode(undef,substr($$dataPt,$pos,$nameLen),'UCS2','II','Latin'); 722 612 $tag =~ s/^WM\///; # remove leading "WM/" 723 613 $pos += $nameLen; … … 738 628 # Inputs: 0) ExifTool object reference, 1) dirInfo ref, 2) tag table reference 739 629 # Returns: 1 on success 740 sub ProcessP review($$$)630 sub ProcessPicture($$$) 741 631 { 742 632 my ($exifTool, $dirInfo, $tagTablePtr) = @_; 743 my $verbose = $exifTool->Options('Verbose');744 633 my $dataPt = $$dirInfo{DataPt}; 745 634 my $dirStart = $$dirInfo{DirStart}; … … 755 644 if ($str =~ /^((?:..)*?)\0\0((?:..)*?)\0\0/) { 756 645 my ($mime, $desc) = ($1, $2); 757 $exifTool->HandleTag($tagTablePtr, 1, $ mime);758 $exifTool->HandleTag($tagTablePtr, 2, $ desc) if length $desc;646 $exifTool->HandleTag($tagTablePtr, 1, $exifTool->Decode($mime,'UCS2','II')); 647 $exifTool->HandleTag($tagTablePtr, 2, $exifTool->Decode($desc,'UCS2','II')) if length $desc; 759 648 } 760 649 $exifTool->HandleTag($tagTablePtr, 3, substr($$dataPt, $dirStart+5+$n, $picLen)); … … 769 658 { 770 659 my ($exifTool, $dirInfo, $tagTablePtr) = @_; 771 my $verbose = $exifTool->Options('Verbose');772 660 my $dataPt = $$dirInfo{DataPt}; 773 661 my $dirLen = $$dirInfo{DirLen}; … … 785 673 $pos += 4; 786 674 return 0 if $pos + $nameLen + 2 > $dirLen; 787 my $name = $exifTool-> Unicode2Charset(substr($$dataPt,$pos,$nameLen),'II');675 my $name = $exifTool->Decode(substr($$dataPt,$pos,$nameLen),'UCS2','II'); 788 676 $exifTool->HandleTag($tagTablePtr, "${type}Name", $name); 789 677 my $descLen = Get16u($dataPt, $pos + $nameLen) * 2; 790 678 $pos += $nameLen + 2; 791 679 return 0 if $pos + $descLen + 2 > $dirLen; 792 my $desc = $exifTool-> Unicode2Charset(substr($$dataPt,$pos,$descLen),'II');680 my $desc = $exifTool->Decode(substr($$dataPt,$pos,$descLen),'UCS2','II'); 793 681 $exifTool->HandleTag($tagTablePtr, "${type}Description", $desc); 794 682 my $infoLen = Get16u($dataPt, $pos + $descLen); … … 805 693 { 806 694 my ($exifTool, $dirInfo, $tagTablePtr) = @_; 807 my $verbose = $exifTool->Options('Verbose');808 695 my $dataPt = $$dirInfo{DataPt}; 809 696 my $dirLen = $$dirInfo{DirLen}; … … 818 705 $pos += 12; 819 706 return 0 if $pos + $nameLen + $dLen > $dirLen; 820 my $tag = Image::ExifTool:: Unicode2Latin(substr($$dataPt,$pos,$nameLen),'v');707 my $tag = Image::ExifTool::Decode(undef,substr($$dataPt,$pos,$nameLen),'UCS2','II','Latin'); 821 708 my $val = ReadASF($exifTool,$dataPt,$pos+$nameLen,$dType,$dLen); 822 709 $exifTool->HandleTag($tagTablePtr, $tag, $val, … … 841 728 my $rtnVal = 0; 842 729 my $pos = 0; 843 my ($buff, $err, @parentTable, @childEnd, %dumpParms); 844 845 if ($verbose > 2) { 846 $dumpParms{MaxLen} = 96 unless $verbose > 3; 847 $dumpParms{Prefix} = $$exifTool{INDENT}; 848 $dumpParms{Out} = $exifTool->Options('TextOut'); 849 } 730 my ($buff, $err, @parentTable, @childEnd); 731 850 732 for (;;) { 851 733 last unless $raf->Read($buff, 24) == 24; … … 856 738 last unless $tag eq '75B22630-668E-11CF-A6D9-00AA0062CE6C'; 857 739 my $fileType = $exifTool->{FILE_EXT}; 858 $fileType = 'ASF' unless $fileType and $fileType =~ /^(ASF|WMV|WMA )$/;740 $fileType = 'ASF' unless $fileType and $fileType =~ /^(ASF|WMV|WMA|DIVX)$/; 859 741 $exifTool->SetFileType($fileType); 860 742 SetByteOrder('II'); … … 868 750 } 869 751 if ($size > 0x7fffffff) { 870 $err = 'Large ASF objects not supported'; 752 if ($size > 0x7fffffff * 4294967296) { 753 $err = 'Invalid ASF object size'; 754 } elsif ($exifTool->Options('LargeFileSupport')) { 755 if ($raf->Seek($size, 1)) { 756 $exifTool->VPrint(0, " Skipped large ASF object ($size bytes)\n"); 757 $pos += $size; 758 next; 759 } 760 $err = 'Error seeking past large ASF object'; 761 } else { 762 $err = 'Large ASF objects not supported (LargeFileSupport not set)'; 763 } 871 764 last; 872 765 } … … 876 769 $tagTablePtr = pop @parentTable; 877 770 $exifTool->{INDENT} = substr($exifTool->{INDENT},0,-2); 878 $dumpParms{Prefix} = $exifTool->{INDENT};879 771 } 880 772 my $tagInfo = $exifTool->GetTagInfo($tagTablePtr, $tag); … … 889 781 if ($verbose > 2) { 890 782 $raf->Read($buff, $s) == $s or $err = 'Truncated file', last; 891 Image::ExifTool::HexDump(\$buff, undef, %dumpParms);783 $exifTool->VerboseDump(\$buff); 892 784 } elsif (not $raf->Seek($s, 1)) { 893 785 $err = 'Seek error'; … … 901 793 if ($verbose) { 902 794 $exifTool->{INDENT} .= '| '; 903 $dumpParms{Prefix} = $exifTool->{INDENT};904 795 $exifTool->VerboseDir($$tagInfo{Name}); 905 796 } … … 913 804 DirName => $$tagInfo{Name}, 914 805 ); 915 if ($verbose > 2) { 916 Image::ExifTool::HexDump(\$buff, undef, %dumpParms); 917 } 806 $exifTool->VerboseDump(\$buff) if $verbose > 2; 918 807 unless ($exifTool->ProcessDirectory(\%subdirInfo, $subTable)) { 919 808 $exifTool->Warn("Error processing $$tagInfo{Name} directory"); … … 929 818 if ($verbose > 2) { 930 819 $raf->Read($buff, $size) == $size or $err = 'Truncated file', last; 931 Image::ExifTool::HexDump(\$buff, undef, %dumpParms);820 $exifTool->VerboseDump(\$buff); 932 821 } elsif (not $raf->Seek($size, 1)) { # skip the block 933 822 $err = 'Seek error'; … … 960 849 =head1 AUTHOR 961 850 962 Copyright 2003-20 07, Phil Harvey (phil at owl.phy.queensu.ca)851 Copyright 2003-2011, Phil Harvey (phil at owl.phy.queensu.ca) 963 852 964 853 This library is free software; you can redistribute it and/or modify it
Note:
See TracChangeset
for help on using the changeset viewer.