<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#------------------------------------------------------------------------------
# File:         MPC.pm
#
# Description:  Read Musepack audio meta information
#
# Revisions:    11/14/2006 - P. Harvey Created
#
# References:   1) http://www.musepack.net/
#------------------------------------------------------------------------------

package Image::ExifTool::MPC;

use strict;
use vars qw($VERSION);
use Image::ExifTool qw(:DataAccess :Utils);
use Image::ExifTool::FLAC;

$VERSION = '1.01';

# MPC metadata blocks
%Image::ExifTool::MPC::Main = (
    PROCESS_PROC =&gt; \&amp;Image::ExifTool::FLAC::ProcessBitStream,
    GROUPS =&gt; { 2 =&gt; 'Audio' },
    NOTES =&gt; q{
        Tags used in Musepack (MPC) audio files.  ExifTool also extracts ID3 and APE
        information from these files.
    },
    'Bit032-063' =&gt; 'TotalFrames',
    'Bit080-081' =&gt; {
        Name =&gt; 'SampleRate',
        PrintConv =&gt; {
            0 =&gt; 44100,
            1 =&gt; 48000,
            2 =&gt; 37800,
            3 =&gt; 32000,
        },
    },
    'Bit084-087' =&gt; {
        Name =&gt; 'Quality',
        PrintConv =&gt; {
             1 =&gt; 'Unstable/Experimental',
             5 =&gt; '0',
             6 =&gt; '1',
             7 =&gt; '2 (Telephone)',
             8 =&gt; '3 (Thumb)',
             9 =&gt; '4 (Radio)',
            10 =&gt; '5 (Standard)',
            11 =&gt; '6 (Xtreme)',
            12 =&gt; '7 (Insane)',
            13 =&gt; '8 (BrainDead)',
            14 =&gt; '9',
            15 =&gt; '10',
       },
    },
    'Bit088-093' =&gt; 'MaxBand',
    'Bit096-111' =&gt; 'ReplayGainTrackPeak',
    'Bit112-127' =&gt; 'ReplayGainTrackGain',
    'Bit128-143' =&gt; 'ReplayGainAlbumPeak',
    'Bit144-159' =&gt; 'ReplayGainAlbumGain',
    'Bit179' =&gt; {
        Name =&gt; 'FastSeek',
        PrintConv =&gt; { 0 =&gt; 'No', 1 =&gt; 'Yes' },
    },
    'Bit191' =&gt; {
        Name =&gt; 'Gapless',
        PrintConv =&gt; { 0 =&gt; 'No', 1 =&gt; 'Yes' },
    },
    'Bit216-223' =&gt; {
        Name =&gt; 'EncoderVersion',
        PrintConv =&gt; '$val =~ s/(\d)(\d)(\d)$/$1.$2.$3/; $val',
    },
);

#------------------------------------------------------------------------------
# Extract information from an MPC file
# Inputs: 0) ExifTool object reference, 1) dirInfo reference
# - Just looks for MPC trailer if FileType is already set
# Returns: 1 on success, 0 if this wasn't a valid MPC file
sub ProcessMPC($$)
{
    my ($et, $dirInfo) = @_;

    # must first check for leading ID3 information
    unless ($$et{DoneID3}) {
        require Image::ExifTool::ID3;
        Image::ExifTool::ID3::ProcessID3($et, $dirInfo) and return 1;
    }
    my $raf = $$dirInfo{RAF};
    my $buff;

    # check MPC signature
    $raf-&gt;Read($buff, 32) == 32 and $buff =~ /^MP\+(.)/s or return 0;
    my $vers = ord($1) &amp; 0x0f;
    $et-&gt;SetFileType();

    # extract audio information (currently only from version 7 MPC files)
    if ($vers == 0x07) {
        SetByteOrder('II');
        my $pos = $raf-&gt;Tell() - 32;
        if ($et-&gt;Options('Verbose')) {
            $et-&gt;VPrint(0, "MPC Header (32 bytes):\n");
            $et-&gt;VerboseDump(\$buff, DataPos =&gt; $pos);
        }
        my $tagTablePtr = GetTagTable('Image::ExifTool::MPC::Main');
        my %dirInfo = ( DataPt =&gt; \$buff, DataPos =&gt; $pos );
        $et-&gt;ProcessDirectory(\%dirInfo, $tagTablePtr);
    } else {
        $et-&gt;Warn('Audio info currently not extracted from this version MPC file');
    }

    # process APE trailer if it exists
    require Image::ExifTool::APE;
    Image::ExifTool::APE::ProcessAPE($et, $dirInfo);

    return 1;
}

1;  # end

__END__

=head1 NAME

Image::ExifTool::MPC - Read Musepack audio meta information

=head1 SYNOPSIS

This module is used by Image::ExifTool

=head1 DESCRIPTION

This module contains definitions required by Image::ExifTool to extract meta
information from Musepack (MPC) audio files.

=head1 AUTHOR

Copyright 2003-2015, Phil Harvey (phil at owl.phy.queensu.ca)

This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=head1 REFERENCES

=over 4

=item L&lt;http://www.musepack.net/&gt;

=back

=head1 SEE ALSO

L&lt;Image::ExifTool::TagNames/MPC Tags&gt;,
L&lt;Image::ExifTool(3pm)|Image::ExifTool&gt;

=cut

</pre></body></html>