| 1 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 2 | # File: MPC.pm | ||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||
| 4 | # Description: Read Musepack audio meta information | ||||||||||||||||||||||||||||
| 5 | # | ||||||||||||||||||||||||||||
| 6 | # Revisions: 11/14/2006 - P. Harvey Created | ||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||
| 8 | # References: 1) http://www.musepack.net/ | ||||||||||||||||||||||||||||
| 9 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | package Image::ExifTool::MPC; | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Image::ExifTool qw(:DataAccess :Utils); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Image::ExifTool::FLAC; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 1 | $VERSION = '1.01'; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | # MPC metadata blocks | ||||||||||||||||||||||||||||
| 21 | 1 | %Image::ExifTool::MPC::Main = ( | |||||||||||||||||||||||||||
| 22 | PROCESS_PROC => \&Image::ExifTool::FLAC::ProcessBitStream, | ||||||||||||||||||||||||||||
| 23 | GROUPS => { 2 => 'Audio' }, | ||||||||||||||||||||||||||||
| 24 | NOTES => q{ | ||||||||||||||||||||||||||||
| 25 | Tags used in Musepack (MPC) audio files. ExifTool also extracts ID3 and APE | ||||||||||||||||||||||||||||
| 26 | information from these files. | ||||||||||||||||||||||||||||
| 27 | }, | ||||||||||||||||||||||||||||
| 28 | 'Bit032-063' => 'TotalFrames', | ||||||||||||||||||||||||||||
| 29 | 'Bit080-081' => { | ||||||||||||||||||||||||||||
| 30 | Name => 'SampleRate', | ||||||||||||||||||||||||||||
| 31 | PrintConv => { | ||||||||||||||||||||||||||||
| 32 | 0 => 44100, | ||||||||||||||||||||||||||||
| 33 | 1 => 48000, | ||||||||||||||||||||||||||||
| 34 | 2 => 37800, | ||||||||||||||||||||||||||||
| 35 | 3 => 32000, | ||||||||||||||||||||||||||||
| 36 | }, | ||||||||||||||||||||||||||||
| 37 | }, | ||||||||||||||||||||||||||||
| 38 | 'Bit084-087' => { | ||||||||||||||||||||||||||||
| 39 | Name => 'Quality', | ||||||||||||||||||||||||||||
| 40 | PrintConv => { | ||||||||||||||||||||||||||||
| 41 | 1 => 'Unstable/Experimental', | ||||||||||||||||||||||||||||
| 42 | 5 => '0', | ||||||||||||||||||||||||||||
| 43 | 6 => '1', | ||||||||||||||||||||||||||||
| 44 | 7 => '2 (Telephone)', | ||||||||||||||||||||||||||||
| 45 | 8 => '3 (Thumb)', | ||||||||||||||||||||||||||||
| 46 | 9 => '4 (Radio)', | ||||||||||||||||||||||||||||
| 47 | 10 => '5 (Standard)', | ||||||||||||||||||||||||||||
| 48 | 11 => '6 (Xtreme)', | ||||||||||||||||||||||||||||
| 49 | 12 => '7 (Insane)', | ||||||||||||||||||||||||||||
| 50 | 13 => '8 (BrainDead)', | ||||||||||||||||||||||||||||
| 51 | 14 => '9', | ||||||||||||||||||||||||||||
| 52 | 15 => '10', | ||||||||||||||||||||||||||||
| 53 | }, | ||||||||||||||||||||||||||||
| 54 | }, | ||||||||||||||||||||||||||||
| 55 | 'Bit088-093' => 'MaxBand', | ||||||||||||||||||||||||||||
| 56 | 'Bit096-111' => 'ReplayGainTrackPeak', | ||||||||||||||||||||||||||||
| 57 | 'Bit112-127' => 'ReplayGainTrackGain', | ||||||||||||||||||||||||||||
| 58 | 'Bit128-143' => 'ReplayGainAlbumPeak', | ||||||||||||||||||||||||||||
| 59 | 'Bit144-159' => 'ReplayGainAlbumGain', | ||||||||||||||||||||||||||||
| 60 | 'Bit179' => { | ||||||||||||||||||||||||||||
| 61 | Name => 'FastSeek', | ||||||||||||||||||||||||||||
| 62 | PrintConv => { 0 => 'No', 1 => 'Yes' }, | ||||||||||||||||||||||||||||
| 63 | }, | ||||||||||||||||||||||||||||
| 64 | 'Bit191' => { | ||||||||||||||||||||||||||||
| 65 | Name => 'Gapless', | ||||||||||||||||||||||||||||
| 66 | PrintConv => { 0 => 'No', 1 => 'Yes' }, | ||||||||||||||||||||||||||||
| 67 | }, | ||||||||||||||||||||||||||||
| 68 | 'Bit216-223' => { | ||||||||||||||||||||||||||||
| 69 | Name => 'EncoderVersion', | ||||||||||||||||||||||||||||
| 70 | PrintConv => '$val =~ s/(\d)(\d)(\d)$/$1.$2.$3/; $val', | ||||||||||||||||||||||||||||
| 71 | }, | ||||||||||||||||||||||||||||
| 72 | ); | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | #------------------------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 75 | # Extract information from an MPC file | ||||||||||||||||||||||||||||
| 76 | # Inputs: 0) ExifTool object reference, 1) dirInfo reference | ||||||||||||||||||||||||||||
| 77 | # - Just looks for MPC trailer if FileType is already set | ||||||||||||||||||||||||||||
| 78 | # Returns: 1 on success, 0 if this wasn't a valid MPC file | ||||||||||||||||||||||||||||
| 79 | sub ProcessMPC($$) | ||||||||||||||||||||||||||||
| 80 | 2 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
ProcessMPC: called CC=7 SCAR=20.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 81 | 2 | my ($et, $dirInfo) = @_; | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | # must first check for leading ID3 information | ||||||||||||||||||||||||||||
| 84 | 2 | ▶ | unless ($$et{DoneID3}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | 1 | require Image::ExifTool::ID3; | |||||||||||||||||||||||||||
| 86 | 1 | ▶ | Image::ExifTool::ID3::ProcessID3($et, $dirInfo) and return 1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | 1 | my $raf = $$dirInfo{RAF}; | |||||||||||||||||||||||||||
| 89 | 1 | my $buff; | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | # check MPC signature | ||||||||||||||||||||||||||||
| 92 | 1 | ▶ | $raf->Read($buff, 32) == 32 and $buff =~ /^MP\+(.)/s or return 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$raf->Read($buff, 32) == 32 and $buff =~ /^MP\+(.)/s
MC/DC0%0/2
$raf->Read($buff, 32) == 32 and $buff =~ /^MP\+(.)/s
$raf->Read($buff, 32) == 32
$buff =~ /^MP\+(.)/s
Truth table33%1/3
A and B
A= $raf->Read($buff, 32) == 32B= $buff =~ /^MP\+(.)/s
| |||||||||||||||||||||||||||||
| 93 | 1 | my $vers = ord($1) & 0x0f; | |||||||||||||||||||||||||||
| 94 | 1 | $et->SetFileType(); | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | # extract audio information (currently only from version 7 MPC files) | ||||||||||||||||||||||||||||
| 97 | 1 | ▶ | if ($vers == 0x07) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 1 | SetByteOrder('II'); | |||||||||||||||||||||||||||
| 99 | 1 | my $pos = $raf->Tell() - 32; | |||||||||||||||||||||||||||
| 100 | 1 | ▶ | if ($et->Options('Verbose')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 0 | $et->VPrint(0, "MPC Header (32 bytes):\n"); | |||||||||||||||||||||||||||
| 102 | 0 | $et->VerboseDump(\$buff, DataPos => $pos); | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | 1 | my $tagTablePtr = GetTagTable('Image::ExifTool::MPC::Main'); | |||||||||||||||||||||||||||
| 105 | 1 | my %dirInfo = ( DataPt => \$buff, DataPos => $pos ); | |||||||||||||||||||||||||||
| 106 | 1 | $et->ProcessDirectory(\%dirInfo, $tagTablePtr); | |||||||||||||||||||||||||||
| 107 | } else { | ||||||||||||||||||||||||||||
| 108 | 0 | $et->Warn('Audio info currently not extracted from this version MPC file'); | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | # process APE trailer if it exists | ||||||||||||||||||||||||||||
| 112 | 1 | require Image::ExifTool::APE; | |||||||||||||||||||||||||||
| 113 | 1 | Image::ExifTool::APE::ProcessAPE($et, $dirInfo); | |||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | 1 | return 1; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 1 | 1; # end | |||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | __END__ | ||||||||||||||||||||||||||||