Info/MPEG/System.pm

filter: Statementstmt 79.1% 144 / 182 Branchbran 48.7% 38 / 78 Conditioncond 40.0% 6 / 15 MC/DCmcdc 10.0% 1 / 10 Subroutinesub 100% 17 / 17 Podpod 0.0% 0 / 12 totaltotal 65.6% 206 / 314 CC 45 SCAR 23.4
CC
45
Cov
68%
skip_packet_header
31.4
parse
14.7
process_packs
9.0
CRAP 10.4
« Info/RIFF.pm ↑ Summary Info/MPEG.pm »
1 ##------------------------------------------------------------------------
2 ## Package: Video::Info::MPEG::System
3 ## Author: Benjamin R. Ginter
4 ## Notice: Copyright (c) 2002 Benjamin R. Ginter
5 ## Purpose: Parse system streams
6 ## Comments: None
7 ## CVS: $Id: System.pm,v 1.3 2002/11/12 07:19:34 allenday Exp $
8 ##------------------------------------------------------------------------
9  
10 package Video::Info::MPEG::System;
11 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 5 ▶use Video::Info::MPEG;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 5 ▶use Video::Info::MPEG::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 5 ▶use constant DEBUG => 0;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use base qw(Video::Info::MPEG);
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 ##------------------------------------------------------------------------
19 ## Preloaded methods go here.
20 ##------------------------------------------------------------------------
21 5 1;
22  
23 ##------------------------------------------------------------------------
24 ## new()
25 ##
26 ## override superclass constructor
27 ##------------------------------------------------------------------------
28 6 ▶sub init {
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
29 6 my $self = shift;
30 6 my %param = @_;
31 6 $self->init_attributes(@_);
32 6 $self->handle($self->filename);
33 6 $self->version(0);
34 6 $self->offset(0);
35 6 $self->last_offset(0);
36 6 $self->{audio} = Video::Info::MPEG::Audio->new(-file => $self->filename);
37 6 $self->{video} = Video::Info::MPEG::Video->new(-context => 'system',
38 -file => $self->filename
39 );
40 }
41  
42 27 ▶sub audio { return shift->{audio} }
Subroutine audio: called CC=1 SCAR=0.0
Pod undocumented
43 24 ▶sub video { return shift->{video} }
Subroutine video: called CC=1 SCAR=0.0
Pod undocumented
44  
45 ##------------------------------------------------------------------------
46 ## parse()
47 ##
48 ## Parse a system packet.
49 ##
50 ## Strategy:
51 ## - Find the first PACK sequence start code
52 ## - Search for additional packs ( process_packs() )
53 ## -
54 ##------------------------------------------------------------------------
55 3 ▶sub parse {
Subroutine parse: called CC=12 SCAR=26.8
Pod undocumented
56 3 my ($self,$offset) = @_;
57  
58 3 my $fh = $self->handle;
59 3 ▶ $offset = 0 if !defined $offset;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $offset 3 0 3
60  
61 3 my ( $pack_start, $pack_len, $pack_head, $packet_size, $packet_type );
62  
63 3 print "Video::Info::MPEG::System::parse( $offset )\n" if DEBUG;
64  
65 ##--------------------------------------------------------------------
66 ## Verify we're dealing with a system stream by trying to fetch the
67 ## first sequence start code (ssc). Save the offset if we succeed.
68 ##--------------------------------------------------------------------
69 3 ▶ $self->is_system( $offset ) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->is_system($offset) or return 0 3 0 3
70 # $offset = $self->_last_offset if defined $self->_last_offset;
71 3 $offset = 12;
72  
73 ##--------------------------------------------------------------------
74 ## Find the remaining packs and process them, returning if we find any
75 ## audio or video tracks. We handle padding packets here too.
76 ##--------------------------------------------------------------------
77 3 ▶ $self->process_packs( $offset ) or return 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->process_packs($offset) or return 0 3 0 3
78  
79 # print "OFFSET: $offset $self->{last_offset}\n";
80 3 $offset = $self->_last_offset - 13;
81  
82 ## okay, this is a miracle but we have what we wanted here
83 ## video!
84 3 ▶ if ( !$self->video->parse( $offset ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->video->parse($offset)) 0 3 3
85 0 print "parse_system: call to parse_video() failed\n" if DEBUG;
86 0 return 0;
87 }
88 ## now get the pack and the packet header just before the video sequence
89 3 my $main_offset = $offset;
90 3 print "Finding audio\n" if DEBUG;
91 3 ▶ if ( $self->next_start_code( AUDIO_PKT, $offset + $self->header_size ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->next_start_code(192, $offset + $self->header_size)) 3 0 3
92 3 print "Found it at ", $self->_last_offset, "\n" if DEBUG;
93 3 my $audio_offset = $self->skip_packet_header( $self->{last_offset} );
94 3 print "AUDIO OFFSET: $audio_offset $self->{last_offset} \n" if DEBUG;
95
96 3 ▶ if ( !$self->audio->parse( $audio_offset ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->audio->parse($audio_offset)) 3 0 3
97 3 ▶ while ( $audio_offset < $self->filesize - 10 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($audio_offset < $self->filesize - 10) 12 0 12
98 ## mm, audio packet doesn't begin with FFF
99 # print "OFFSET: $audio_offset\n" if DEBUG;
100 12 ▶ if ( $self->audio->parse( $audio_offset ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->audio->parse($audio_offset)) 3 9 12
101 3 last;
102 }
103
104 9 $audio_offset++; ## is this ok?
105 }
106 }
107 # print "Parsed audio OK!\n";
108  
109 }
110  
111 ## seek the file duration by fetching the last PACK
112 ## and reading its timestamp
113 3 ▶ if ( $self->next_start_code( PACK_PKT, $self->filesize - 2500 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->next_start_code(186, $self->filesize - 2500)) 3 0 3
114 # print "Found final PACK at $self->{last_offset}\n";
115 }
116 3 my $byte = $self->get_byte( $self->{last_offset} + 4 );
117
118 ## see if it's a standard MPEG1
119 3 ▶ if ( $byte & 0xF0 == 0x20 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($byte & !1) { } 0 3 3
120 0 $self->duration( $self->read_ts( 1, $self->{last_offset} + 4 ) );
121 }
122 ## no?
123 else {
124 ## Is it MPEG2?
125 3 ▶ if ( $byte & 0xC0 == 0x40 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($byte & !1) { } 0 3 3
126 0 print "TS: ", $self->read_ts( 2, $self->{last_offset} + 4 ), "\n" if DEBUG;
127 }
128 ## try mpeg1 anyway
129 else {
130 3 $self->duration( $self->read_ts( 1, $self->{last_offset} + 4) );
131 }
132 }
133
134 3 return 1;
135 }
136  
137 ##------------------------------------------------------------------------
138 ## process_packs()
139 ##
140 ## Step through the bitstream and process each type of pack encountered,
141 ## stopping if we find any audio or video tracks.
142 ##------------------------------------------------------------------------
143 3 ▶sub process_packs {
Subroutine process_packs: called CC=8 SCAR=22.0
Pod undocumented
144 3 my ( $self, $offset ) = @_;
145 3 my $fh = $self->handle;
146  
147 3 print "\n", '-' x 74, "\nSearching for start code packets\n", '-' x 74, "\n" if DEBUG;
148  
149 3 ▶ while ( $offset <= $self->filesize ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($offset <= $self->filesize) 9 0 9
150 ## print '-' x 20, '[ LOOP ]', '-' x 20, "\n" if DEBUG;
151 ## print "OFFSET: $offset\n" if DEBUG;
152
153 ## Find next start code
154 9 my $code = $self->next_start_code( undef, $offset );
155  
156 9 $offset = $self->_last_offset;
157 printf( "Found marker '%s' (0x%02x) at %d\n",
158 9 $STREAM_ID->{$code}, ## Note the uppercase. This is defined in Constants.pm
159 $code,
160 $offset ) if DEBUG;
161  
162
163 ##----------------------------------------------------------------
164 ## We found what we're looking for (VIDEO or AUDIO)
165 ##----------------------------------------------------------------
166 9 ▶ last if $code == VIDEO_PKT || $code == AUDIO_PKT;
Branch: 1 branch
BranchTrueFalseTotal
if $code == 224 or $code == 192 3 6 9
Condition66%2/3
$code == 224 or $code == 192
l!l&&r!l&&!r
306
MC/DC50%1/2
$code == 224 or $code == 192
$code == 224 $code == 192
Truth table66%2/3
A or B
A= $code == 224B= $code == 192
ABresult
1X1
011
000
167  
168 ##----------------------------------------------------------------
169 ## if this is a PADDING packet for byte alignment
170 ##----------------------------------------------------------------
171 6 ▶ if ( $code == PADDING_PKT ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($code == 190) { } 0 6 6
elsif ($code == 186) { } 3 3 6
elsif ($code == 187) { } 3 0 3
172 # print "\t\tFound Padding Packet at $offset\n";
173 0 $offset += $self->grab( 2, $offset + 4 );
174 # print "Skipped to $offset\n";
175 0 next;
176 }
177  
178 ##----------------------------------------------------------------
179 ## if this is a PACK
180 ##----------------------------------------------------------------
181 elsif ( $code == PACK_PKT ) {
182 3 $self->{muxrate} = $self->get_mux_rate( $offset + 4);
183 3 $offset += 12;
184 3 next;
185 }
186
187 ##----------------------------------------------------------------
188 ## It has to be a system packet
189 ##----------------------------------------------------------------
190 elsif ( $code == SYS_PKT ) {
191 3 my $len = $self->parse_sys_pkt( $offset );
192
193 3 ▶ if ( $len ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($len) 3 0 3
194 3 $offset = $len;
195 3 next;
196 }
197 }
198  
199 ##----------------------------------------------------------------
200 ## No more guessing
201 ##----------------------------------------------------------------
202 else {
203 printf( "1: Unhandled packet encountered '%s' ( 0x%02x ) at offset %d\n",
204 0 $STREAM_ID->{$code},
205 $code,
206 $offset ) if DEBUG;
207 # $offset += 4;
208 # next;
209 }
210  
211 0 $offset += 4;
212 }
213  
214 3 return 1;
215 }
216  
217 ##------------------------------------------------------------------------
218 ## is_system()
219 ##
220 ## Verify this is a system stream.
221 ##------------------------------------------------------------------------
222 3 ▶sub is_system {
Subroutine is_system: called CC=2 SCAR=7.6
Pod undocumented
223 3 my ( $self, $offset ) = @_;
224  
225 3 print "\n", '-' x 74, "\nLooking for System Start Packet\n", '-' x 74, "\n" if DEBUG;
226  
227  
228 3 ▶ if ( !$self->next_start_code( PACK_PKT, 0 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->next_start_code(186, 0)) 0 3 3
229 0 print "Couldn't find packet start code\n" if DEBUG;
230 0 return 0;
231 }
232  
233 3 print "Warning: junk at the beginning!\n" if DEBUG && $self->_last_offset;
234 3 return 1;
235 }
236  
237 ##------------------------------------------------------------------------
238 ## get_streams
239 ##
240 ## Parse a system packet and extract the number of streams.
241 ##------------------------------------------------------------------------
242 3 ▶sub get_streams {
Subroutine get_streams: called CC=7 SCAR=20.3
Pod undocumented
243 3 my ( $self, $offset ) = @_;
244
245 3 print "\n", '-' x 74, "\nGetting Stream Counts\n", '-' x 74, "\n" if DEBUG;
246  
247 3 my $stream_count_token = $self->grab( 2, $offset + 4 ) - 6;
248  
249 3 ▶ return 0 if $stream_count_token % 3 != 0;
Branch: 1 branch
BranchTrueFalseTotal
if $stream_count_token % 3 != 0 0 3 3
250  
251 3 ▶ for ( my $i = 0; $i < $stream_count_token / 3; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $stream_count_token / 3) 6 3 9
252 6 my $code = $self->get_byte( $offset + 12 + $i * 3 );
253
254 6 ▶ if ( ( $code & 0xf0 ) == AUDIO_PKT ) {
Branch: 2 branches
BranchTrueFalseTotal
if (($code & 240) == 192) { } 3 3 6
elsif (($code & 240) == 224 or ($code & 240) == 208) { } 3 0 3
255 # print "Audio Stream\n" if DEBUG;
256 3 $self->{astreams}++;
257 }
258 ▶ elsif ( ( $code & 0xf0 ) == VIDEO_PKT || ( $code & 0xf0 ) == 0xD0 ) {
Condition33%1/3
($code & 240) == 224 or ($code & 240) == 208
l!l&&r!l&&!r
300
MC/DC0%0/2
($code & 240) == 224 or ($code & 240) == 208
($code & 240) == 224 ($code & 240) == 208
Truth table33%1/3
A or B
A= ($code & 240) == 224B= ($code & 240) == 208
ABresult
1X1
011
000
259 # print "Video Stream\n" if DEBUG;
260 3 $self->{vstreams}++;
261 }
262 }
263  
264 3 $self->astreams( $self->{astreams} );
265 3 $self->vstreams( $self->{vstreams} );
266 # print "\t", $self->astreams, " audio\n";
267 # print "\t", $self->vstreams, " video\n";
268  
269 3 ▶ return 1 if $self->vstreams;
Branch: 1 branch
BranchTrueFalseTotal
if $self->vstreams 3 0 3
270  
271 0 return 0;
272 }
273  
274 ##------------------------------------------------------------------------
275 ## get_version()
276 ##
277 ## Sets the MPEG version.
278 ##------------------------------------------------------------------------
279 3 ▶sub get_version {
Subroutine get_version: called CC=3 SCAR=13.8
Pod undocumented
280 3 my ( $self, $offset ) = @_;
281  
282 3 print "\n", '-' x 74, "\nGetting Version\n", '-' x 74, "\n" if DEBUG;
283  
284 ##--------------------------------------------------------------------
285 ## Check for variable length PACK in mpeg2
286 ##--------------------------------------------------------------------
287 3 $offset = 0;
288 3 $self->{pack_len} = 0;
289 3 my $pack_head = $self->get_byte( $offset + 4 );
290
291 3 ▶ if ( ( $pack_head & 0xF0 ) == 0x20 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($pack_head & 240) == 32) { } 3 0 3
292 3 $self->vcodec('MPEG1');
293 3 print "MPEG1\n" if DEBUG;
294 3 $self->{pack_len} = 12;
295 }
296 else {
297 0 ▶ if ( ( $pack_head & 0xC0 ) == 0x40 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($pack_head & 192) == 64) { } 0 0 0
298 ## new mpeg2 pack : 14 bytes + stuffing
299 0 $self->vcodec('MPEG2');
300 0 print "MPEG2\n" if DEBUG;
301 0 $self->{pack_len} = 14 + $self->get_byte( $offset + 13 ) & 0x07;
302 }
303 else {
304 ## whazzup?!
305 0 printf "Weird pack encountered! 0x%02x\n", $pack_head if DEBUG;
306 0 $self->{pack_len} = 12;
307 0 return 0;
308 }
309 }
310
311 3 return 1;
312 }
313  
314 ##------------------------------------------------------------------------
315 ## parse_sys_pkt()
316 ##
317 ## Parse a system packet
318 ##------------------------------------------------------------------------
319 3 ▶sub parse_sys_pkt {
Subroutine parse_sys_pkt: called CC=7 SCAR=21.6
Pod undocumented
320 3 my ( $self, $offset ) = @_;
321 3 my $fh = $self->handle;
322  
323 3 print "\n", '-' x 74, "\nParsing System Packet\n", '-' x 74, "\n" if DEBUG;
324  
325 ## Get the MPEG version then the number of audio and video streams.
326 3 ▶ $self->get_version( $offset ) or die "Can't get MPEG version\n";
Branch: 1 branch
BranchTrueFalseTotal
$self->get_version($offset) or die "Can't get MPEG version\n" 3 0 3
327 3 ▶ $self->get_streams( $offset ) or die "Strange number of packets!\n";
Branch: 1 branch
BranchTrueFalseTotal
$self->get_streams($offset) or die "Strange number of packets!\n" 3 0 3
328  
329 # print "Getting packet size\n" if DEBUG;
330 3 my $packet_size = $self->grab( 2, $offset + 4 );
331  
332 # print "Getting packet type\n" if DEBUG;
333 3 my $packet_type = $self->get_byte( $offset + 12 );
334  
335 3 my $byte = $self->get_byte( $offset + 15 );
336 # printf "PACKET_TYPE: %02x\n", $packet_type;
337 # printf "BYTE: %02x\n", $byte;
338  
339 3 my $header_len = 0;
340  
341 3 ▶ if ( $byte == AUDIO_PKT || $byte == VIDEO_PKT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($byte == 192 or $byte == 224) 3 0 3
Condition33%1/3
$byte == 192 or $byte == 224
l!l&&r!l&&!r
300
MC/DC0%0/2
$byte == 192 or $byte == 224
$byte == 192 $byte == 224
Truth table33%1/3
A or B
A= $byte == 192B= $byte == 224
ABresult
1X1
011
000
342 # print "System packet with both audio and video\n" if DEBUG;
343 3 $packet_type = VIDEO_PKT; ## since video is mandatory
344
345 3 $header_len = $self->{pack_len} + 6 + $packet_size;
346  
347 ## We could grab the entire video header here and pass it off
348 ## to MPEG::Info::Video to avoid the seek/read penalties
349 }
350
351 ##--------------------------------------------------------------------
352 ## If we ever encounter a packet with multiple audio or video streams,
353 ## we can implement this.
354 ##--------------------------------------------------------------------
355 3 ▶ if ( $packet_type != AUDIO_PKT && $packet_type != VIDEO_PKT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($packet_type != 192 and $packet_type != 224) 0 3 3
Condition33%1/3
$packet_type != 192 and $packet_type != 224
!ll&&!rl&&r
030
MC/DC0%0/2
$packet_type != 192 and $packet_type != 224
$packet_type != 192 $packet_type != 224
Truth table33%1/3
A and B
A= $packet_type != 192B= $packet_type != 224
ABresult
0X0
100
111
356 0 printf "Unknown system packet '%s', %x @ $offset\n", $STREAM_ID->{$packet_type},
357 $packet_type if DEBUG;
358 0 return 0;
359 }
360  
361 3 print "\n", '-' x 74, "\nEnd System Packet Parse\n", '-' x 74, "\n" if DEBUG;
362 3 return $header_len;
363 }
364  
365 ##------------------------------------------------------------------------
366 ## read_ts()
367 ##
368 ## Read an MPEG-1 or MPEG-2 timestamp
369 ##------------------------------------------------------------------------
370 3 ▶sub read_ts {
Subroutine read_ts: called CC=3 SCAR=11.2
Pod undocumented
371 3 my $self = shift;
372 3 my $type = shift;
373 3 my $offset = shift;
374  
375 3 my $ts = 0;
376  
377 3 ▶ if ( $type == 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type == 1) { } 3 0 3
elsif ($type == 2) { } 0 0 0
378 3 my $highbit = ( $self->get_byte( $offset ) >> 3 ) & 0x01;
379 3 my $low4bytes = ( ( $self->get_byte( $offset ) >> 1 ) & 0x30 ) << 30;
380 3 $low4bytes |= ( $self->get_byte( $offset + 1 ) << 22 );
381 3 $low4bytes |= ( ( $self->get_byte( $offset + 2 ) >> 1 ) << 15 );
382 3 $low4bytes |= ( $self->get_byte( $offset + 3 ) << 7 );
383 3 $low4bytes |= ( $self->get_byte( $offset + 4 ) >> 1 );
384  
385 3 $ts = $highbit * ( 1 << 16 );
386 3 $ts += $low4bytes;
387 3 $ts /= 90000;
388 }
389 elsif ( $type == 2 ) {
390 0 print "Define mpeg-2 timestamps\n" if DEBUG;
391 }
392 3 return $ts;
393  
394 }
395  
396 ##------------------------------------------------------------------------
397 ## skip_packet_header()
398 ##
399 ## Skip a packet header
400 ##------------------------------------------------------------------------
401 3 ▶sub skip_packet_header {
Subroutine skip_packet_header: called CC=7 SCAR=34.5
Pod undocumented
402 3 my $self = shift;
403 3 my $offset = shift;
404  
405 3 ▶ if ( $self->version == 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->version == 1) { } 0 3 3
elsif ($self->version == 2) { } 0 3 3
406 ## skip startcode and packet size
407 0 $offset += 6;
408  
409 ## remove stuffing bytes
410 0 my $byte = $self->get_byte( $offset );
411  
412 0 ▶ while ( $byte & 0x80 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($byte & 128) 0 0 0
413 0 $byte = $self->get_byte( ++$offset );
414 }
415  
416 ## next two bytes are 01
417 0 ▶ if ( ( $byte & 0xC0 ) == 0x40 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($byte & 192) == 64) 0 0 0
418 0 $offset += 2;
419 }
420
421 0 $byte = $self->get_byte( $offset );
422  
423 0 ▶ if ( ( $byte & 0xF0 ) == 0x20 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (($byte & 240) == 32) { } 0 0 0
elsif (($byte & 240) == 48) { } 0 0 0
424 0 $offset += 5;
425 }
426 elsif ( ( $byte & 0xF0 ) == 0x30 ) {
427 0 $offset += 10;
428 }
429 else {
430 0 $offset++;
431 }
432  
433 # print "1. Returning offset of $offset\n" if DEBUG;
434
435 0 return $offset;
436 }
437 elsif ( $self->version == 2 ) {
438 ## this is a PES, easyer
439 ## offset + 9 is the header length (-9)
440  
441 # print "2. Returning offset of ", $offset + 9 + ( $self->get_byte + 8 ), "\n" if DEBUG;
442 0 return $offset + 9 + ( $self->get_byte + 8 );
443 }
444 else {
445 # print "3. Returning offset of ", $offset + 10, "\n" if DEBUG;
446 3 return $offset + 10;
447 }
448 }
449  
450 ##------------------------------------------------------------------------
451 ## get_mux_rate()
452 ##
453 ## Calculate the mux rate
454 ##------------------------------------------------------------------------
455 3 ▶sub get_mux_rate {
Subroutine get_mux_rate: called CC=4 SCAR=15.4
Pod undocumented
456 3 my $self = shift;
457 3 ▶ my $offset = shift || $self->{offset};
Condition33%1/3
shift() || $self->{'offset'}
l!l&&r!l&&!r
300
MC/DC0%0/2
shift() || $self->{'offset'}
shift() $self->{'offset'}
Truth table33%1/3
A || B
A= shift()B= $self->{'offset'}
ABresult
1X1
011
000
458  
459 3 print "\n", '-' x 74, "\nGetting Muxrate @ $offset\n", '-' x 74, "\n" if DEBUG;
460  
461 3 my $muxrate = 0;
462  
463 3 my $byte = $self->get_byte( $offset );
464  
465 3 ▶ if ( ( $byte & 0xC0 ) == 0x40 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($byte & 192) == 64) { } 0 3 3
466 0 $muxrate = $self->get_byte( $offset + 6 ) << 14;
467 0 $muxrate |= $self->get_byte( $offset + 7 ) << 6;
468 0 $muxrate |= $self->get_byte( $offset + 8 ) >> 2;
469 }
470 else {
471 ## maybe mpeg1
472 3 ▶ if ( ( $byte & 0xf0 ) != 0x20 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($byte & 240) != 32) 0 3 3
473 0 print "Weird pack header while parsing muxrate (offset ", $offset, ")\n" if DEBUG;
474 # die;
475 }
476  
477 3 $muxrate = ( $self->get_byte( $offset + 5 ) & 0x7f ) << 15;
478 3 $muxrate |= $self->get_byte( $offset + 6 ) << 7;
479 3 $muxrate |= $self->get_byte( $offset + 7 ) >> 1;
480 }
481
482 3 $muxrate *= 50;
483 3 return $muxrate;
484 }
485  
486  
487  
488 __END__
« Info/RIFF.pm ↑ Summary Info/MPEG.pm »