Branch Coverage

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


line true false branch
109 0 0 unless my $info = get_mp3info($file)
127 0 0 unless ref $self
129 0 0 if exists $$self{$name}
137 0 0 if (exists $$self{$name}) { }
140 0 0 if (defined $_[1])
148 0 0 exists $MP3::Info::v1_tag_fields{$name} ? :
196 4 0 if ($val == 1)
198 4 0 if ($unicode_base_module)
258 0 16 unless (defined $file and $file ne '')
263 0 16 unless (-s $file)
268 0 16 if (ref $file) { }
271 0 16 unless (open $fh, '+<', $file)
279 16 0 if ($version eq 1 or $version eq 'ALL')
282 5 11 if (<$fh> =~ /^TAG/)
283 0 5 unless truncate $fh, $tell
288 16 0 if ($version eq 2 or $version eq 'ALL')
290 6 10 if ($v2h)
304 0 6 unless truncate $fh, $eof - $$v2h{'tag_size'}
352 5 65 defined $_ ? :
356 5 0 if ref $title
359 0 5 if (not $ref) { }
5 0 elsif ($ref eq 'HASH') { }
376 0 5 unless (defined $file and $file ne '')
381 0 5 unless (-s $file)
387 5 0 if $info{'TRACKNUM'}
391 5 0 if ($^W)
394 0 25 unless defined $info{$field}
395 0 25 if (length $info{$field} > $MP3::Info::v1_tag_fields{$field})
401 5 0 if ($info{'GENRE'})
402 0 5 unless exists $MP3::Info::mp3_genres{$info{'GENRE'}}
407 5 0 if ($info{'TRACKNUM'})
409 0 5 unless ($info{'TRACKNUM'} =~ /^\d+$/ and $info{'TRACKNUM'} > 0 and $info{'TRACKNUM'} < 256)
411 0 0 if $^W
417 0 5 if (ref $file) { }
420 0 5 unless (open $fh, '+<', $file)
430 2 3 <$fh> =~ /^TAG/ ? :
433 5 0 $info{'GENRE'} && exists $MP3::Info::mp3_genres{$info{'GENRE'}} ? :
438 5 0 if ($info{'TRACKNUM'}) { }
499 0 0 $ver == 2 || $ver == 1 ? :
14 0 !$ver ? :
501 0 14 unless (defined $file and $file ne '')
508 0 14 unless ($filesize)
514 0 14 if (ref $file) { }
520 0 14 unless (open $fh, $file)
530 0 14 if ($find_ape)
535 14 0 if ($ver < 2)
539 0 14 if ($ver == 1 and not $has_v1)
546 14 0 if ($ver == 2 or $ver == 0)
550 0 0 unless ($has_v1 or $has_v2 or $has_ape)
556 14 0 unless ($raw and $ver == 2)
561 105 0 if (defined $info{$key})
568 7 91 unless defined $info{$_}
572 0 14 if (keys %info and not defined $info{'GENRE'})
578 14 0 keys %info ? :
587 6 8 unless (defined $tag and $tag =~ /^TAG/)
592 7 1 if (substr($tag, -3, 2) =~ /\000[^\000]/) { }
610 0 8 unless ($UNICODE)
621 0 63 unless $$info{$key}
624 0 63 if ($unicode_detect_module)
629 0 0 if ($enc)
640 0 63 unless (ref $icode)
650 0 0 if ref $icode
659 63 0 ref $icode ? :
675 0 6 if ($$v2{'TXXX'} and ref $$v2{'TXXX'} ne 'ARRAY')
682 0 6 if (ref $$v2{'COMM'} eq 'ARRAY' and grep {/Media Jukebox/;} @{$$v2{'COMM'};})
686 0 0 if ($comment =~ /Media Jukebox/)
696 0 6 $raw_v2 == 2 ? :
700 60 36 unless exists $$v2{$id}
702 0 36 if ($id =~ /^UFID?$/) { }
0 36 elsif ($id =~ /^RVA[D2]?$/) { }
0 36 elsif ($id =~ /^A?PIC$/) { }
706 0 0 if $#ufid_list > 0
711 0 0 if ($id eq 'RVA2') { }
0 0 elsif ($id eq 'RVAD' or $id eq 'RVA') { }
723 0 0 if (int $peakBytes / 8)
745 0 0 if ($val == -255) { }
751 0 0 $flags & 1 ? :
766 0 0 if (ref $pic eq 'ARRAY')
777 0 0 if ($pic and $id eq 'PIC') { }
0 0 elsif ($pic and $id eq 'APIC') { }
784 0 0 if ($encoding)
786 0 0 if ($pic_len < length $pic)
798 0 0 if ($pic_len < length $pic)
805 0 0 if ($encoding == 1 or $encoding == 2)
813 0 0 if ($valid_pic and $pic_format)
817 0 0 if (length $data and $pic_format)
829 36 0 if ref $data1 ne 'ARRAY'
841 6 30 if ($id =~ /^(COM[M ]?|US?LT)$/)
848 36 0 if ($UNICODE) { }
850 0 36 if ($encoding eq "\cA" or $encoding eq "\cB") { }
0 36 elsif ($encoding eq "\cC") { }
36 0 elsif ($encoding eq "\000") { }
869 0 36 if ($data and not $data =~ /^[\x00-\x7F]+$/)
871 0 0 if ($unicode_detect_module) { }
876 0 0 if ($enc)
885 0 0 if (ref $dec) { }
901 0 0 if ($data =~ s/^\xFF\xFE//) { }
0 0 elsif ($data =~ s/^\xFE\xFF//) { }
903 0 0 /^(..)$/ && !/(\xFF\xFE)/ ? :
907 0 0 /^(..)$/ && !/(\xFF\xFE)/ ? :
911 0 0 if ($pat)
913 0 0 /^(..)$/ && !/(\x00\x00)/ ? :
914 0 0 chr($_) =~ /[[:ascii:]]/ && chr($_) =~ /[[:print:]]/ ? :
924 6 30 if ($id =~ /^(COM[M ]?|US?LT)$/) { }
6 24 elsif ($id =~ /^TCON?$/) { }
24 0 elsif ($id =~ /^T...?$/ and $id ne 'TXXX') { }
931 0 6 if ($encoding eq "\cA" or $encoding eq "\cB")
947 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/) { }
967 0 0 if ($data =~ s/^ ( [^\(]\D+ ) ( \000 | \( | \Z)/$2/x) { }
986 0 6 if ($name and $name ne "\000") { }
6 0 elsif (defined $index) { }
993 0 6 if ($data and ref $data eq 'ARRAY' and scalar @$data == 1)
1013 0 0 if ($data =~ /\x00/ and $raw_v2 == 2 || $raw_v2 == 0)
1024 0 36 if ($desc)
1028 0 0 if ($raw_v2 == 2) { }
0 0 elsif ($desc =~ /^iTun/) { }
1039 0 36 if ($raw_v2 == 2 and exists $$info{$$hash{$id}}) { }
1041 0 0 if (ref $$info{$$hash{$id}} eq 'ARRAY') { }
1050 0 36 if ($id eq 'TXXX') { }
0 36 elsif ($id eq 'PRIV') { }
1055 0 0 if ($encoding eq "\cA" or $encoding eq "\cB")
1074 0 36 if ($ver == 2 and $$info{$key} and not ref $$info{$key}) { }
0 36 elsif ($ver == 2 and ref $$info{$key} eq 'ARRAY') { }
1076 0 0 if (ref $data eq 'ARRAY') { }
1088 0 0 if (ref $data eq 'ARRAY') { }
1119 8 6 if (<$fh> =~ /^TAG/)
1126 0 14 if (my $v2f = _get_v2foot($fh))
1129 0 0 _get_v2tagdata($fh, $ver, $raw, $info, $eof) ? :
1133 6 8 _get_v2tagdata($fh, $ver, $raw, $info, $start) ? :
1150 0 105 if (ref $$info{$name} eq 'ARRAY')
1158 0 0 if (defined $ielement)
1162 0 0 if defined $o and defined $chk[$o] and $ielement eq $chk[$o]
1169 0 0 if ($#array == 0) { }
1197 8 6 unless $v2h = _get_v2head($fh, $start)
1199 0 6 if ($$v2h{'major_version'} < 2)
1200 0 0 if $^W
1208 2 4 $$v2h{'major_version'} > 3 ? :
1217 2 4 if ($$v2h{'major_version'} == 2) { }
1232 0 6 if $$v2h{'major_version'} == 2 and $$v2h{'compression'}
1236 0 6 if ($$v2h{'update'})
1242 0 6 if ($$v2h{'offset'} + $end > $size)
1258 2 4 if ($$v2h{'major_version'} == 4)
1262 0 6 if $$v2h{'unsync'}
1279 0 42 unless $wholetag
1285 6 36 unless ($bytes =~ /^([A-Z0-9\? ]{$num})/)
1302 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)
1321 0 0 if $MP3::Info::debug_24
1327 0 12 if ($$v2h{'major_version'} == 4 and $id3v2_4_frame_size_broken == 0 and $size > 128 + $hlen and $off + $size < $end)
1333 0 0 if $MP3::Info::debug_24
1337 0 0 if (not $morebytes =~ /^([A-Z0-9]{4})/ || $morebytes =~ /^\x00{4}/) { }
1344 0 0 if $MP3::Info::debug_24
1354 0 0 if (length $wholetag >= $off + $retrysize + 4) { }
1363 0 0 unless ($morebytes =~ /^([A-Z0-9]{4})/ or $morebytes =~ /^\x00{4}/ or $off + $retrysize > $end)
1370 0 0 if $MP3::Info::debug_24
1374 0 0 if $MP3::Info::debug_24
1387 0 0 if $MP3::Info::debug_24
1395 12 24 if ($$v2h{'major_version'} == 4) { }
12 12 elsif ($$v2h{'major_version'} == 3) { }
1415 6 36 unless my($id, $size, $flags) = &$myseek
1420 0 36 if ($$flags{'frame_encrypt'})
1435 0 36 if ($$flags{'data_len_indicator'})
1447 0 36 if $MP3::Info::debug_24
1450 0 36 if $$flags{'frame_unsync'} and not $$v2h{'unsync'}
1456 0 36 if ($$flags{'data_len_indicator'} and defined $data_len)
1457 0 0 unless $data_len == length $bytes
1469 20 16 if ($$v2h{'major_version'} == 3 || $$v2h{'major_version'} == 4 and $id =~ /^T/)
1475 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$/) { }
1478 0 0 if $MP3::Info::debug_Tencoding
1484 0 0 if $MP3::Info::debug_Tencoding
1492 0 36 if (exists $$v2{$id}) { }
1494 0 0 if (ref $$v2{$id} eq 'ARRAY') { }
1508 6 0 if ($ver == 0 || $ver == 2 and $v2)
1510 0 6 if ($raw == 1 and $ver == 2) { }
1520 0 6 if ($ver == 0 and $$info{'TAGVERSION'}) { }
1570 0 6 unless (defined $file and $file ne '')
1577 0 6 if (ref $file) { }
1580 0 6 unless ($size)
1585 0 6 unless (open $fh, '<', $file)
1595 0 6 if ($MP3::Info::try_harder)
1603 0 6 if (my $v2h = _get_v2head($fh))
1606 0 0 if ($off > $size - 10)
1619 6 0 unless ($is_mp3)
1631 0 1944 if $tot - $i < 4
1635 1878 66 if ord $head != 255
1639 6 60 if $is_mp3
1645 0 6 if ($off > $tot and not $MP3::Info::try_harder)
1661 6 0 <$fh> =~ /^TAG/ ? :
6 0 if <$fh> =~ /^TAG/ ? 1 : 0
1667 0 6 if (my $v2f = _get_v2foot($fh))
1683 0 6 unless ($$h{'bitrate'} and $$h{'fs'})
1687 0 0 $$h{'IDR'} == 0 ? :
3 0 $$h{'IDR'} == 3 ? :
3 3 $$h{'IDR'} == 2 ? :
1690 0 6 if (ref $vbr eq 'HASH' and $$vbr{'is_vbr'} == 1) { }
1696 0 6 $$h{'copyright'} ? :
1697 0 6 $$h{'padding_bit'} ? :
1698 3 3 $$h{'mode'} == 3 ? :
1701 0 6 $$i{'VBR'} == 1 && $$vbr{'bytes'} ? :
1704 3 3 $$h{'ID'} ? :
1705 0 6 $$i{'VBR'} == 1 && $$vbr{'frames'} ? :
1710 0 6 if ($$i{'VBR'} == 1)
1711 0 0 if $$vbr{'scale'}
1713 0 0 unless ($$h{'bitrate'})
1730 6 0 if $$i{'FRAMES'}
1733 0 6 if ($lame)
1762 0 72 unless my $h = $_[0]
1815 3 3 if ($$h{'ID'}) { }
1816 0 3 $$h{'mode'} == 3 ? :
1818 3 0 $$h{'mode'} == 3 ? :
1823 0 6 if ($bytes =~ /(?:Xing|Info)/) { }
0 6 elsif ($bytes =~ /(?:VBRI)/) { }
1825 0 0 if $bytes =~ /Xing/
1830 0 0 if ($vbr{'flags'} & 1)
1835 0 0 if ($vbr{'flags'} & 2)
1840 0 0 if ($vbr{'flags'} & 4)
1846 0 0 if ($vbr{'flags'} & 8) { }
1890 6 0 unless $bytes =~ /^LAME/
1908 0 36 unless my $fh = $_[0]
1922 36 0 if ($$v2h{'offset'} == 0)
1925 0 36 if ($tag eq 'RIF' or $tag eq 'FOR')
1926 0 0 unless _find_id3_chunk($fh, $tag)
1934 24 12 if $tag ne 'ID3'
1946 4 8 if ($$v2h{'major_version'} == 2) { }
1955 4 4 if $$v2h{'major_version'} == 4
1967 0 12 if $$v2h{'footer'}
1977 0 12 if ($$v2h{'ext_header'})
1984 0 0 $$v2h{'major_version'} > 3 ? :
1992 0 0 if ($$v2h{'ext_header_size'} - 10 > -s $fh)
1999 0 0 if ($$v2h{'major_version'} == 3) { }
0 0 elsif ($$v2h{'major_version'} == 4) { }
2007 0 0 if (defined $bytes[2 + $i])
2042 0 20 unless my $fh = $_[0]
2052 20 0 unless $bytes eq '3DI'
2063 0 0 if ($$v2h{'major_version'} != 4) { }
2072 0 0 unless ($$v2h{'footer'})
2101 0 0 if ($bytes ne 'ID3')
2125 0 0 if ($filetype eq 'RIF') { }
0 0 elsif ($filetype eq 'FOR') { }
2139 0 0 if $tag eq $mat
2189 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') { }
2233 0 0 if (my $offset = _parse_lyrics3_tag($fh, $filesize, $info)) { }
2244 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) { }
2260 0 0 if (keys %{$ape_footer;})
2264 0 0 if ($$ape_footer{'flags'}{'header'}) { }
2284 0 0 if (defined $$ape_header{'version'})
2285 0 0 if ($$ape_header{'version'} == 2000) { }
2293 0 0 if (defined $$ape_header{'tag_items'} and $$ape_header{'tag_items'} =~ /^\d+$/)
2319 0 0 if (substr($bytes, 0, 8, '') eq 'APETAGEX')
2330 0 0 $data{'global_flags'} & 2147483648 ? :
2331 0 0 $data{'global_flags'} & 1073741824 ? :
2332 0 0 $data{'global_flags'} & 536870912 ? :
2340 41 0 unless (ref $file)
2341 0 41 unless close $fh
2518 36 12 $_ ? :