Branch Coverage

lib/Image/Info/AVIF.pm
Criterion Covered Total %
branch 41 94 43.6


line true false branch
12 2 0 if ("$]" >= 5.008) { }
25 105 105 if $dlen == $len
27 0 105 if (not defined $n) { }
0 105 elsif ($n == 0) { }
39 0 3 unless defined $d and $d =~ /\x00\z/
51 24 18 if ($type =~ /$box_types_to_keep/ and not exists $boxes{$type})
55 0 42 if ($len == 1)
59 0 0 unless $len >> 32 == $lenhi
61 0 42 unless $len >= $pos
64 42 0 $len < 65536 ? :
66 24 18 if defined $bufp
79 0 3 if (not eval { do { local $SIG{'__DIE__'}; my $boxes = &read_heif($source, qr/\A(?:ftyp|meta)\z/); my $ftyp = $boxes->{'ftyp'}; &die_for_info("no ftyp box") unless defined $ftyp; &die_for_info("malformed ftyp box") unless length $ftyp >= 8 and not length $ftyp & 3; &die_for_info("major brand is not \"avif\"") unless substr($ftyp, 0, 4) eq "avif"; $info->replace_info(0, "file_media_type", "image/avif"); $info->replace_info(0, "file_ext", "avif"); my $mboxes; { my $meta = $boxes->{'meta'}; &die_for_info("no meta box") unless defined $meta; my $metafh = &io_string($meta); &die_for_info("malformed meta box") unless &read_block($metafh, 1) eq "\0"; &read_block($metafh, 3); $mboxes = &read_heif($metafh, qr/\A(?:hdlr|iprp)\z/); } ; { my $hdlr = $mboxes->{'hdlr'}; &die_for_info("no hdlr box") unless defined $hdlr; my $hdlrfh = &io_string($hdlr); &die_for_info("malformed hdlr box") unless &read_block($hdlrfh, 1) eq "\0"; &read_block($hdlrfh, 3); &die_for_info("non-zero pre-defined value") unless unpack("N", &read_block($hdlrfh, 4)) == 0; &die_for_info("handler type is not \"pict\"") unless &read_block($hdlrfh, 4) eq "pict"; &read_block($hdlrfh, 12); &read_nulterm($hdlrfh); } ; my $pboxes; { my $iprp = $mboxes->{'iprp'}; &die_for_info("no iprp box") unless defined $iprp; my $iprpfh = &io_string($iprp); $pboxes = &read_heif($iprpfh, qr/\Aipco\z/); } ; my $cboxes; { my $ipco = $pboxes->{'ipco'}; &die_for_info("no ipco box") unless defined $ipco; my $ipcofh = &io_string($ipco); $cboxes = &read_heif($ipcofh, qr/\A(?:irot|clap|ispe|pixi|colr|pasp)\z/); } ; my $rot = 0; if (defined(my $irot = $cboxes->{'irot'})) { &die_for_info("malformed irot box") unless length $irot >= 1; my($angle) = unpack("C", $irot); &die_for_info("malformed irot box") if $angle & -4; $rot = 1 if $angle & 1; } ; if (defined(my $clap = $cboxes->{'clap'})) { &die_for_info("malformed clap box") unless length $clap >= 32; my($width_num, $width_den, $height_num, $height_den) = unpack("NNNN", $clap); &die_for_info("malformed clap box") unless $width_den != 0 and $height_den != 0; my $width = int $width_num / $width_den; my $height = int $height_num / $height_den; ($width, $height) = ($height, $width) if $rot; $info->replace_info(0, "width", $width); $info->replace_info(0, "height", $height); } elsif (defined(my $ispe = $cboxes->{'ispe'})) { &die_for_info("malformed ispe box") unless length $ispe >= 12; my($ver, undef, $width, $height) = unpack("Ca3NN", $ispe); &die_for_info("malformed ispe box") unless $ver == 0; ($width, $height) = ($height, $width) if $rot; $info->replace_info(0, "width", $width); $info->replace_info(0, "height", $height); } ; if (defined(my $pixi = $cboxes->{'pixi'})) { &die_for_info("malformed pixi box") unless length $pixi >= 5; my($ver, undef, $planes) = unpack("Ca3C", $pixi); &die_for_info("malformed pixi box") unless $ver == 0; &die_for_info("malformed pixi box") unless length $pixi >= 5 + $planes; $info->replace_info(0, "SamplesPerPixel", $planes); $info->replace_info(0, "BitsPerSample", [map({unpack "C", substr($pixi, 5 + $_, 1);} 0 .. $planes - 1)]); } ; if (defined(my $colr = $cboxes->{'colr'})) { &die_for_info("malformed colr box") unless length $colr >= 4; my $type = substr($colr, 0, 4); if ($type eq "nclx") { &die_for_info("malformed colr box") unless length $colr >= 11; my($prim) = unpack("n", substr($colr, 4, 2)); if (defined(my $ctype = $primaries_type[$prim])) { $info->replace_info(0, "color_type", $ctype); } ; } ; } ; if (defined(my $pasp = $cboxes->{'pasp'})) { &die_for_info("malformed pasp box") unless length $pasp >= 8; my($hspc, $vspc) = unpack("NN", $pasp); $info->replace_info(0, "resolution", "$vspc/$hspc"); } ; 1 } })
82 0 3 unless defined $ftyp
83 0 3 unless length $ftyp >= 8 and not length $ftyp & 3
85 0 3 unless substr($ftyp, 0, 4) eq "avif"
92 0 3 unless defined $meta
94 0 3 unless &read_block($metafh, 1) eq "\0"
101 0 3 unless defined $hdlr
103 0 3 unless &read_block($hdlrfh, 1) eq "\0"
106 0 3 unless unpack("N", &read_block($hdlrfh, 4)) == 0
108 0 3 unless &read_block($hdlrfh, 4) eq "pict"
116 0 3 unless defined $iprp
123 0 3 unless defined $ipco
129 0 3 if (defined(my $irot = $cboxes->{'irot'}))
130 0 0 unless length $irot >= 1
132 0 0 if $angle & -4
133 0 0 if $angle & 1
135 0 3 if (defined(my $clap = $cboxes->{'clap'})) { }
3 0 elsif (defined(my $ispe = $cboxes->{'ispe'})) { }
136 0 0 unless length $clap >= 32
139 0 0 unless $width_den != 0 and $height_den != 0
143 0 0 if $rot
147 0 3 unless length $ispe >= 12
149 0 3 unless $ver == 0
150 0 3 if $rot
154 3 0 if (defined(my $pixi = $cboxes->{'pixi'}))
155 0 3 unless length $pixi >= 5
157 0 3 unless $ver == 0
158 0 3 unless length $pixi >= 5 + $planes
163 3 0 if (defined(my $colr = $cboxes->{'colr'}))
164 0 3 unless length $colr >= 4
166 3 0 if ($type eq "nclx")
167 0 3 unless length $colr >= 11
169 3 0 if (defined(my $ctype = $primaries_type[$prim]))
174 0 3 if (defined(my $pasp = $cboxes->{'pasp'}))
175 0 0 unless length $pasp >= 8
182 0 0 if (ref $err eq 'Image::Info::AVIF::__ERROR__') { }