| 1 | package Video::Info::ASF; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use constant DEBUG => 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 2 | our $VERSION = '1.01'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Video::Info; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use base qw(Video::Info); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | ######################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # ASF GUID signatures | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | #base ASF object guids | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use constant Header => 0x75b22630; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use constant data => 0x75b22636; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 2 | ▶ | use constant simple_index => 0x33000890; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | #header object guids | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 2 | ▶ | use constant file_properties => 0x8cabdca1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 2 | ▶ | use constant stream_properties => 0xb7dc0791; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | use constant stream_bitrate_properties => 0x7bf875ce; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | ▶ | use constant content_description => 0x75b22633; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | ▶ | use constant extended_content_encryption => 0x298ae614; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | use constant script_command => 0x1efb1a30; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | ▶ | use constant marker => 0xf487cd01; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | use constant header_extension => 0x5fbf03b5; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | use constant bitrate_mutual_exclusion => 0xd6e229dc; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 2 | ▶ | use constant codec_list => 0x86d15240; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | use constant extended_content_description => 0xd2d0a440; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | ▶ | use constant error_correction => 0x75b22635; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | use constant stream_bitrate_porperties => 0x7bf875ce; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | ▶ | use constant padding => 0x1806d474; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | #stream properties object stream type guids | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | ▶ | use constant audio_media => 0xf8699e40; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | use constant video_media => 0xbc19efc0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | ▶ | use constant command_media => 0x59dacfc0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | #stream properties object error correction type guids | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | use constant no_error_correction => 0x20fb5700; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | use constant audio_spread => 0xbfc3cd50; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | #mutual exclusion object exclusion type guids | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | ▶ | use constant mutex_bitrate => 0xd6e22a01; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 2 | ▶ | use constant mutex_unknown => 0xd6e22a02; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | #from mplayer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 2 | ▶ | use constant audio_conceal_none => 0x49f1a440; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2 | ▶ | use constant header_2_0 => 0xD6E229D1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ######################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 6 | ▶ | sub header { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 6 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 6 | my $val = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 6 | ▶ | return undef unless ref $self; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 6 | ▶ | return $self->{header} unless $val; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | $self->{header} = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 4 | return $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ##------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | ## probe() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | ## Obtain the filehandle from Video::Info and extract the properties from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ## the ASF structure. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | ##------------------------------------------------------------------------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | ▶ | sub init { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | $self->init_attributes(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 4 | ▶ | sub probe { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
probe: called CC=44 SCAR=39.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 4 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 4 | my $fh = $self->handle; ## inherited from Video::Info | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 4 | my $header; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 4 | sysread($fh,$header,24);# or die "died probe(): $!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 4 | ▶ | die "not an ASF" unless unpack("V",substr($header,0,4)) == Header; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 4 | $self->type('ASF'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 4 | my($h1,$h2) = unpack("VV",substr($header,16,8)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 4 | my $headersize = ($h2 * 0xffffffff) + $h1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 4 | my $bytes = sysread($fh,$header,$headersize,24); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 4 | ▶ | die "probe() sysread: $!" unless $bytes = $headersize; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | #warn length($header); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | #exit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 4 | $self->header($header); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 4 | my %guid = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 4 | for(0..$headersize-5){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 6928 | my $window = substr($header,$_,4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 6928 | ▶ | $guid{codec_list} = $_ if(unpack("V",$window)) == codec_list; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 6928 | ▶ | $guid{header} = $_ if(unpack("V",$window)) == Header; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 6928 | ▶ | $guid{audio_media} = $_ if(unpack("V",$window)) == audio_media; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 6928 | ▶ | $guid{video_media} = $_ if(unpack("V",$window)) == video_media; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 6928 | ▶ | $guid{audio_conceal_none} = $_ if(unpack("V",$window)) == audio_conceal_none; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 6928 | ▶ | $guid{audio_spread} = $_ if(unpack("V",$window)) == audio_spread; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 6928 | ▶ | $guid{content_description}= $_ if(unpack("V",$window)) == content_description; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 6928 | ▶ | $guid{data} = $_ if(unpack("V",$window)) == data; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 6928 | ▶ | $guid{simple_index} = $_ if(unpack("V",$window)) == simple_index; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 6928 | ▶ | $guid{stream_properties} = $_ if(unpack("V",$window)) == stream_properties; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 6928 | ▶ | $guid{header_2_0} = $_ if(unpack("V",$window)) == header_2_0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 6928 | ▶ | $guid{file_properties} = $_ if(unpack("V",$window)) == file_properties; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 4 | my @guids = map {$_->[0]} sort {$a->[1] <=> $b->[1]} map {[$_,$guid{$_}]} keys %guid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 4 | ▶ | for(my $i=0;$i<scalar(@guids);$i++){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 31 | my $thisguid = $guids[$i]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 31 | my $nextguid = $guids[$i+1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | #print $thisguid,"\t",$nextguid,"\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 31 | my $thisguidpos = $guid{$thisguid}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 31 | ▶ | my $nextguidpos = $nextguid ? $guid{$nextguid} : length($header); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 31 | my $head = substr($header,$thisguidpos,$nextguidpos - $thisguidpos - 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 31 | my $guid = unpack("V",substr($head,0,4)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | #warn "guid $thisguid: ".$thisguidpos."-".$nextguidpos; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 31 | ▶ | if($guid == Header){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 12 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 4 | warn "Header" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | #noop yet. we should switch modes depending on whether or not we have a 1.0 or 2.0 header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } elsif($guid == header_2_0){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | warn "Header 2.0" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | #no exmple yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | die "header_2_0. Please email allenday\@ucla.edu"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | elsif($guid == codec_list){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 3 | warn "codec_list" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 3 | ▶ | next unless length($head) >= 40; #prevent substr() errors on bad headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 3 | my($codecs) = unpack("V",substr($head,40,4)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | #print $head, "\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | #print "\ttotal codecs: $codecs\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 3 | my $offset = 44; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 3 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 3 | ▶ | while($i < $codecs){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 6 | my($type,$namelen) = unpack("vv",substr($head,$offset,4)); $offset += 4; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | #print "\tcodec type: $type "; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | #print $type == 0x0000 ? "video\n" : #this is not standard by ASF 1.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | # $type == 0x0001 ? "video\n" : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | # $type == 0x0002 ? "audio\n" : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | # $type == 0xffff ? "unknown\n" : "huh?\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 6 | $namelen *= 2; #because it is a unicode string | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 6 | my $name = substr($head,$offset,$namelen); $offset += $namelen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | #print "\t\tname $namelen: $name\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 6 | ▶ | if($type == 0x0000 || $type == 0x0001){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$type == 0 or $type == 1
MC/DC50%1/2
$type == 0 or $type == 1
$type == 0
$type == 1
Truth table66%2/3
A or B
A= $type == 0B= $type == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 3 | ▶ | $self->vcodec($self->vcodec || $name); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->vcodec || $name
MC/DC0%0/2
$self->vcodec || $name
$self->vcodec
$name
Truth table33%1/3
A || B
A= $self->vcodecB= $name
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 3 | ▶ | $self->vstreams( ($self->vstreams || 0) + 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->vstreams || 0
MC/DC0%0/1
$self->vstreams || 0
$self->vstreams
Truth table50%1/2
A
A= $self->vstreams
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 6 | ▶ | if($type == 0x0002){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 3 | ▶ | $self->acodec($name) unless $self->acodec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 3 | ▶ | $self->astreams( ($self->astreams || 0) + 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->astreams || 0
MC/DC0%0/1
$self->astreams || 0
$self->astreams
Truth table50%1/2
A
A= $self->astreams
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | #we don't worry about these (for now) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 6 | my($desclen) = unpack("v",substr($head,$offset,2)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 6 | $desclen *= 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 6 | my $desc = substr($head,$offset,$desclen); $offset += $desclen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | #print "\t\tdesc: $desc\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 6 | my($infolen) = unpack("v",substr($head,$offset,2)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 6 | $infolen *= 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 6 | my $info = substr($head,$offset,$infolen); $offset += $infolen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | #print "\t\tinfo: $info\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 6 | $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | elsif($guid == file_properties){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 4 | warn "file_properties" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 4 | ▶ | next unless length($head) >= 32; #prevent substr() errors on bad headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 4 | my($size1,$size2,$date1,$date2,$count1,$count2,$dur1,$dur2) = unpack("VVVVVVVV",substr($head,40,32)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 4 | my($maxbitrate) = unpack("V",substr($head,100,4)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | #these are 64bit values, so we have to put them together manually. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | #some systems (like mine) don't support q and Q unpacking. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 4 | my $size = ($size2 * 0xffffffff) + $size1; #filesize in bytes | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 4 | my $date = (($date2 * 0xffffffff) + $date1) / 1_000; #creation time. i have no idea what format --aday | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 4 | my $count = ($count2 * 0xffffffff)+ $count1; #number of data packets in the data object | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 4 | my $dur = (($dur2 * 0xffffffff) + $dur1) / 10_000_000; #was in 100 nanosecond units, zheesh | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | #print "\tsize: $size\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 4 | $self->date($date); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | #print "\tdate: ".$self->date."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | $self->packets($count); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | #print "\tcount: ".$self->count."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 4 | $self->duration($dur); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | #print "\tduration: ".$self->duration."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 4 | $self->vrate($maxbitrate); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | #print "\tmax bitrate: ".$self->vrate."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | elsif($guid == content_description){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 4 | warn "content_description" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 4 | ▶ | next unless length($head) >= 34; #prevent substr() errors on bad headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 4 | my $offset = 34; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 4 | my($titlelen,$authlen,$copylen,$desclen,$ratlen) = unpack("vvvvv",substr($head,24,10)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 4 | my $title = substr($head,$offset,$titlelen); $offset += $titlelen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 4 | my $author = substr($head,$offset,$authlen); $offset += $authlen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 4 | my $copyright = substr($head,$offset,$copylen); $offset += $copylen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 4 | my $description = substr($head,$offset,$desclen); $offset += $desclen; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 4 | my $rating = substr($head,$offset,$ratlen); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 4 | $self->title($title); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 4 | $self->author($author); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 4 | $self->copyright($copyright); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 4 | $self->description($description); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 4 | $self->rating($rating); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | elsif($guid == video_media){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 4 | warn "video_media" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 4 | ▶ | next unless length($head) >= 16; #prevent substr() errors on bad headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 4 | my $codec = substr($head,81,4); #hack. is it really at 81? should be at 16 from 1.0 spec. | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 4 | $self->vcodec($codec); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 4 | my($width,$height,$bpp,$colors) = unpack("VVxxvxxxxxxxxxxxxxxxxV",substr($head,54,32)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 4 | $self->width($width); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 4 | $self->height($height); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | #print "\tbpp: $bpp\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | #print "\tcompression ID: $codec\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | #print "\tcolors used: $colors\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | ▶ | elsif($guid == audio_spread || $guid == audio_media){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$guid == 3217280336 or $guid == 4167671360
MC/DC100%2/2
$guid == 3217280336 or $guid == 4167671360
$guid == 3217280336
$guid == 4167671360
Truth table100%3/3
A or B
A= $guid == 3217280336B= $guid == 4167671360
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 8 | warn "audio" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 8 | ▶ | next unless length($head) >= 18; #prevent substr() errors on bad headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 4 | my($codecID,$achan,$samp,$bpsec,$blk,$bpsamp,$format) = unpack("vvVVvvv",substr($head,38,18)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | #print "\tcodec ID: $codecID\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | #$self->acodec($codecID) unless $self->acodec; #??? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | #print "\tcodec : ".$self->acodec."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | #print "\taudio channels: $achan\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 4 | $self->achans($achan); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | #print "\tsample rate: $samp\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | #print "\tbytes/second: $bpsec\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 4 | $self->arate($bpsec * 8); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | #print "\tblock alignment: $blk\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | #print "\tbits/sample: $bpsamp\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | #print "\tformat: $format\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 4 | $self->acodec($format); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | elsif($guid == script_command) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | warn "script_command" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | #hmm, interesting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | warn "*********************script_command"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | # my($rawsize1,$rawsize2) = unpack("VV",substr($head,16,8)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | # my $objsize = (($rawsize2 * 0xffffffff) + $rawsize1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # my $obj = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | elsif($guid == stream_properties){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 4 | warn "stream_properties" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | #noop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | elsif($guid == data){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | warn "data" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | #noop, this is the movie itself | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | elsif($guid == simple_index){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | warn "simple_index" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | #no example yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | #warn "******************simple_index"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | elsif($guid == audio_conceal_none){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | warn "audio_conceal_none" if DEBUG; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | #no example yet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | #warn "******************audio_conceal_none"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||