Branch Coverage

blib/lib/MP3/Info.pm
Criterion Covered Total %
branch 191 524 36.4


line true false branch
110 0 0 unless my $info = get_mp3info($file)
128 0 0 unless ref $self
130 0 0 if exists $self->{$name}
138 0 0 if (exists $self->{$name}) { }
141 0 0 if (defined $_[1])
149 0 0 exists $MP3::Info::v1_tag_fields{$name} ? :
197 4 0 if ($val == 1)
199 4 0 if ($unicode_base_module)
259 0 16 unless (defined $file and $file ne '')
264 0 16 unless (-s $file)
269 0 16 if (ref $file) { }
272 0 16 unless (open $fh, '+<', $file)
280 16 0 if ($version eq 1 or $version eq 'ALL')
283 5 11 if (readline($fh) =~ /^TAG/)
284 0 5 unless truncate $fh, $tell
289 16 0 if ($version eq 2 or $version eq 'ALL')
291 6 10 if ($v2h)
306 0 6 unless truncate $fh, $eof - $v2h->{'tag_size'}
355 5 65 defined $_ ? :
357 5 0 if ref $title
360 0 5 if (not $ref) { }
5 0 elsif ($ref eq 'HASH') { }
377 0 5 unless (defined $file and $file ne '')
382 0 5 unless (-s $file)
388 5 0 if $info{'TRACKNUM'}
392 5 0 if ($^W)
395 0 25 unless defined $info{$field}
396 0 25 if (length $info{$field} > $MP3::Info::v1_tag_fields{$field})
402 5 0 if ($info{'GENRE'})
404 0 5 unless exists $MP3::Info::mp3_genres{$info{'GENRE'}}
408 5 0 if ($info{'TRACKNUM'})
410 0 5 unless ($info{'TRACKNUM'} =~ /^\d+$/ and $info{'TRACKNUM'} > 0 and $info{'TRACKNUM'} < 256)
412 0 0 if $^W
418 0 5 if (ref $file) { }
421 0 5 unless (open $fh, '+<', $file)
431 2 3 readline($fh) =~ /^TAG/ ? :
435 5 0 $info{'GENRE'} && exists $MP3::Info::mp3_genres{$info{'GENRE'}} ? :
439 5 0 if ($info{'TRACKNUM'}) { }
500 0 0 $ver == 2 || $ver == 1 ? :
14 0 !$ver ? :
502 0 14 unless (defined $file and $file ne '')
509 0 14 unless ($filesize)
515 0 14 if (ref $file) { }
521 0 14 unless (open $fh, $file)
531 0 14 if ($find_ape)
536 14 0 if ($ver < 2)
540 0 14 if ($ver == 1 and not $has_v1)
547 14 0 if ($ver == 2 or $ver == 0)
551 0 0 unless ($has_v1 or $has_v2 or $has_ape)
557 14 0 unless ($raw and $ver == 2)
562 105 0 if (defined $info{$key})
569 7 91 unless defined $info{$_}
573 0 14 if (keys %info and not defined $info{'GENRE'})
579 14 0 keys %info ? :
588 6 8 unless (defined $tag and $tag =~ /^TAG/)
593 7 1 if (substr($tag, -3, 2) =~ /\000[^\000]/) { }
611 0 8 unless ($UNICODE)
622 0 63 unless $info->{$key}
625 0 63 if ($unicode_detect_module)
630 0 0 if ($enc)
641 0 63 unless (ref $icode)
651 0 0 if ref $icode
661 63 0 ref $icode ? :
677 0 6 if ($v2->{'TXXX'} and ref $v2->{'TXXX'} ne 'ARRAY')
684 0 6 if (ref $v2->{'COMM'} eq 'ARRAY' and grep {/Media Jukebox/;} @{$$v2{'COMM'};})
688 0 0 if ($comment =~ /Media Jukebox/)
698 0 6 $raw_v2 == 2 ? :
702 60 36 unless exists $v2->{$id}
704 0 36 if ($id =~ /^UFID?$/) { }
0 36 elsif ($id =~ /^RVA[D2]?$/) { }
0 36 elsif ($id =~ /^A?PIC$/) { }
708 0 0 if $#ufid_list > 0
713 0 0 if ($id eq 'RVA2') { }
0 0 elsif ($id eq 'RVAD' or $id eq 'RVA') { }
725 0 0 if (int $peakBytes / 8)
747 0 0 if ($val == -255) { }
753 0 0 $flags & 1 ? :
768 0 0 if (ref $pic eq 'ARRAY')
779 0 0 if ($pic and $id eq 'PIC') { }
0 0 elsif ($pic and $id eq 'APIC') { }
786 0 0 if ($encoding)
788 0 0 if ($pic_len < length $pic)
800 0 0 if ($pic_len < length $pic)
807 0 0 if ($encoding == 1 or $encoding == 2)
815 0 0 if ($valid_pic and $pic_format)
819 0 0 if (length $data and $pic_format)
831 36 0 if ref $data1 ne 'ARRAY'
843 6 30 if ($id =~ /^(COM[M ]?|US?LT)$/)
850 36 0 if ($UNICODE) { }
852 0 36 if ($encoding eq "\cA" or $encoding eq "\cB") { }
0 36 elsif ($encoding eq "\cC") { }
36 0 elsif ($encoding eq "\000") { }
871 0 36 if ($data and not $data =~ /^[\x00-\x7F]+$/)
873 0 0 if ($unicode_detect_module) { }
878 0 0 if ($enc)
887 0 0 if (ref $dec) { }
903 0 0 if ($data =~ s/^\xFF\xFE//) { }
0 0 elsif ($data =~ s/^\xFE\xFF//) { }
905 0 0 /^(..)$/ && !/(\xFF\xFE)/ ? :
909 0 0 /^(..)$/ && !/(\xFF\xFE)/ ? :
913 0 0 if ($pat)
915 0 0 /^(..)$/ && !/(\x00\x00)/ ? :
917 0 0 chr($_) =~ /[[:ascii:]]/ && chr($_) =~ /[[:print:]]/ ? :
926 6 30 if ($id =~ /^(COM[M ]?|US?LT)$/) { }
6 24 elsif ($id =~ /^TCON?$/) { }
24 0 elsif ($id =~ /^T...?$/ and $id ne 'TXXX') { }
933 0 6 if ($encoding eq "\cA" or $encoding eq "\cB")
949 6 0 if ($data =~ /^ \(? (\d+) \)?\000?$/sx) { }
0 0 elsif ($data =~ /^ \( (\d+) \)\000? ([^\(].+)$/x) { }
0 0 elsif ($data =~ /^ \( (\d+) \)\000?/x) { }
0 0 elsif ($data =~ /^[^\000]+\000/) { }
969 0 0 if ($data =~ s/^ ( [^\(]\D+ ) ( \000 | \( | \Z)/$2/x) { }
988 0 6 if ($name and $name ne "\000") { }
6 0 elsif (defined $index) { }
995 0 6 if ($data and ref $data eq 'ARRAY' and scalar @$data == 1)
1015 0 0 if ($data =~ /\x00/ and $raw_v2 == 2 || $raw_v2 == 0)
1026 0 36 if ($desc)
1030 0 0 if ($raw_v2 == 2) { }
0 0 elsif ($desc =~ /^iTun/) { }
1041 0 36 if ($raw_v2 == 2 and exists $$info{$hash->{$id}}) { }
1043 0 0 if (ref $$info{$hash->{$id}} eq 'ARRAY') { }
1052 0 36 if ($id eq 'TXXX') { }
0 36 elsif ($id eq 'PRIV') { }
1057 0 0 if ($encoding eq "\cA" or $encoding eq "\cB")
1076 0 36 if ($ver == 2 and $info->{$key} and not ref $info->{$key}) { }
0 36 elsif ($ver == 2 and ref $info->{$key} eq 'ARRAY') { }
1078 0 0 if (ref $data eq 'ARRAY') { }
1090 0 0 if (ref $data eq 'ARRAY') { }
1121 8 6 if (readline($fh) =~ /^TAG/)
1128 0 14 if (my $v2f = _get_v2foot($fh))
1131 0 0 _get_v2tagdata($fh, $ver, $raw, $info, $eof) ? :
1135 6 8 _get_v2tagdata($fh, $ver, $raw, $info, $start) ? :
1152 0 105 if (ref $info->{$name} eq 'ARRAY')
1160 0 0 if (defined $ielement)
1164 0 0 if defined $o and defined $chk[$o] and $ielement eq $chk[$o]
1171 0 0 if ($#array == 0) { }
1199 8 6 unless $v2h = _get_v2head($fh, $start)
1201 0 6 if ($v2h->{'major_version'} < 2)
1202 0 0 if $^W
1210 2 4 $v2h->{'major_version'} > 3 ? :
1219 2 4 if ($v2h->{'major_version'} == 2) { }
1234 0 2 if $v2h->{'major_version'} == 2 and $v2h->{'compression'}
1238 0 6 if ($v2h->{'update'})
1244 0 6 if ($v2h->{'offset'} + $end > $size)
1260 2 4 if ($v2h->{'major_version'} == 4)
1264 0 6 if $v2h->{'unsync'}
1281 0 42 unless $wholetag
1287 6 36 unless ($bytes =~ /^([A-Z0-9\? ]{$num})/)
1304 0 12 if ($v2h->{'major_version'} == 4 and $id3v2_4_frame_size_broken == 0 and (($bytes[0] | $bytes[1] | $bytes[2] | $bytes[3]) & 128) != 0 || $off + $size > $end)
1323 0 0 if $MP3::Info::debug_24
1329 0 12 if ($v2h->{'major_version'} == 4 and $id3v2_4_frame_size_broken == 0 and $size > 128 + $hlen and $off + $size < $end)
1335 0 0 if $MP3::Info::debug_24
1339 0 0 if (not $morebytes =~ /^([A-Z0-9]{4})/ || $morebytes =~ /^\x00{4}/) { }
1346 0 0 if $MP3::Info::debug_24
1356 0 0 if (length $wholetag >= $off + $retrysize + 4) { }
1365 0 0 unless ($morebytes =~ /^([A-Z0-9]{4})/ or $morebytes =~ /^\x00{4}/ or $off + $retrysize > $end)
1372 0 0 if $MP3::Info::debug_24
1376 0 0 if $MP3::Info::debug_24
1389 0 0 if $MP3::Info::debug_24
1397 12 24 if ($v2h->{'major_version'} == 4) { }
12 12 elsif ($v2h->{'major_version'} == 3) { }
1417 6 36 unless my($id, $size, $flags) = &$myseek
1422 0 36 if ($flags->{'frame_encrypt'})
1437 0 36 if ($flags->{'data_len_indicator'})
1449 0 36 if $MP3::Info::debug_24
1452 0 36 if $flags->{'frame_unsync'} and not $v2h->{'unsync'}
1458 0 36 if ($flags->{'data_len_indicator'} and defined $data_len)
1459 0 0 unless $data_len == length $bytes
1471 20 16 if ($v2h->{'major_version'} == 3 || $v2h->{'major_version'} == 4 and $id =~ /^T/)
1477 0 20 if ($encoding eq "\000" || $encoding eq "\cC" and not $bytes =~ /\x00$/) { }
0 20 elsif ($encoding eq "\cA" || $encoding eq "\cB" and not $bytes =~ /\x00\x00$/) { }
1480 0 0 if $MP3::Info::debug_Tencoding
1486 0 0 if $MP3::Info::debug_Tencoding
1494 0 36 if (exists $v2->{$id}) { }
1496 0 0 if (ref $v2->{$id} eq 'ARRAY') { }
1510 6 0 if ($ver == 0 || $ver == 2 and $v2)
1512 0 6 if ($raw == 1 and $ver == 2) { }
1522 0 6 if ($ver == 0 and $info->{'TAGVERSION'}) { }
1572 0 6 unless (defined $file and $file ne '')
1579 0 6 if (ref $file) { }
1582 0 6 unless ($size)
1587 0 6 unless (open $fh, '<', $file)
1597 0 6 if ($MP3::Info::try_harder)
1605 0 6 if (my $v2h = _get_v2head($fh))
1608 0 0 if ($off > $size - 10)
1621 6 0 unless ($is_mp3)
1633 0 1944 if $tot - $i < 4
1637 1878 66 if ord $head != 255
1641 6 60 if $is_mp3
1647 0 6 if ($off > $tot and not $MP3::Info::try_harder)
1663 6 0 readline($fh) =~ /^TAG/ ? :
6 0 if readline($fh) =~ /^TAG/ ? 1 : 0
1669 0 6 if (my $v2f = _get_v2foot($fh))
1685 0 6 unless ($h->{'bitrate'} and $h->{'fs'})
1689 0 0 $h->{'IDR'} == 0 ? :
3 0 $h->{'IDR'} == 3 ? :
3 3 $h->{'IDR'} == 2 ? :
1692 0 6 if (ref $vbr eq 'HASH' and $vbr->{'is_vbr'} == 1) { }
1698 0 6 $h->{'copyright'} ? :
1699 0 6 $h->{'padding_bit'} ? :
1700 3 3 $h->{'mode'} == 3 ? :
1703 0 6 $i->{'VBR'} == 1 && $vbr->{'bytes'} ? :
1706 3 3 $h->{'ID'} ? :
1709 0 6 $i->{'VBR'} == 1 && $vbr->{'frames'} ? :
1712 0 6 if ($i->{'VBR'} == 1)
1713 0 0 if $vbr->{'scale'}
1715 0 0 unless ($h->{'bitrate'})
1732 6 0 if $i->{'FRAMES'}
1735 0 6 if ($lame)
1764 0 72 unless my $h = $_[0]
1817 3 3 if ($h->{'ID'}) { }
1818 0 3 $h->{'mode'} == 3 ? :
1820 3 0 $h->{'mode'} == 3 ? :
1825 0 6 if ($bytes =~ /(?:Xing|Info)/) { }
0 6 elsif ($bytes =~ /(?:VBRI)/) { }
1827 0 0 if $bytes =~ /Xing/
1832 0 0 if ($vbr{'flags'} & 1)
1837 0 0 if ($vbr{'flags'} & 2)
1842 0 0 if ($vbr{'flags'} & 4)
1848 0 0 if ($vbr{'flags'} & 8) { }
1892 6 0 unless $bytes =~ /^LAME/
1910 0 36 unless my $fh = $_[0]
1924 36 0 if ($v2h->{'offset'} == 0)
1927 0 36 if ($tag eq 'RIF' or $tag eq 'FOR')
1928 0 0 unless _find_id3_chunk($fh, $tag)
1936 24 12 if $tag ne 'ID3'
1948 4 8 if ($v2h->{'major_version'} == 2) { }
1957 4 4 if $v2h->{'major_version'} == 4
1969 0 12 if $v2h->{'footer'}
1979 0 12 if ($v2h->{'ext_header'})
1986 0 0 $v2h->{'major_version'} > 3 ? :
1994 0 0 if ($v2h->{'ext_header_size'} - 10 > -s $fh)
2001 0 0 if ($v2h->{'major_version'} == 3) { }
0 0 elsif ($v2h->{'major_version'} == 4) { }
2009 0 0 if (defined $bytes[2 + $i])
2044 0 20 unless my $fh = $_[0]
2054 20 0 unless $bytes eq '3DI'
2065 0 0 if ($v2h->{'major_version'} != 4) { }
2074 0 0 unless ($v2h->{'footer'})
2103 0 0 if ($bytes ne 'ID3')
2127 0 0 if ($filetype eq 'RIF') { }
0 0 elsif ($filetype eq 'FOR') { }
2141 0 0 if $tag eq $mat
2191 0 0 if ($lyrics3_end eq 'LYRICSEND') { }
0 0 elsif ($lyrics3_end eq 'LYRICS200') { }
0 0 elsif (substr(reverse($lyrics3_id3v1), 0, 9) eq 'DNESCIRYL') { }
0 0 elsif (substr(reverse($lyrics3_id3v1), 0, 9) eq '002SCIRYL') { }
2235 0 0 if (my $offset = _parse_lyrics3_tag($fh, $filesize, $info)) { }
2246 0 0 if (substr($ape_footer_id3v1, length($ape_footer_id3v1) - $id3v1_tag_size - $ape_tag_header_size, 8) eq $ape_tag_id) { }
0 0 elsif (substr($ape_footer_id3v1, length($ape_footer_id3v1) - $ape_tag_header_size, 8) eq $ape_tag_id) { }
2262 0 0 if (keys %{$ape_footer;})
2266 0 0 if ($ape_footer->{'flags'}{'header'}) { }
2286 0 0 if (defined $ape_header->{'version'})
2287 0 0 if ($ape_header->{'version'} == 2000) { }
2295 0 0 if (defined $ape_header->{'tag_items'} and $ape_header->{'tag_items'} =~ /^\d+$/)
2321 0 0 if (substr($bytes, 0, 8, '') eq 'APETAGEX')
2332 0 0 $data{'global_flags'} & 2147483648 ? :
2333 0 0 $data{'global_flags'} & 1073741824 ? :
2334 0 0 $data{'global_flags'} & 536870912 ? :
2342 41 0 unless (ref $file)
2343 0 41 unless close $fh
2520 36 12 $_ ? :