submersible_toaster has asked for the wisdom of the Perl Monks concerning the following question:
Since posting this I realised that two particular issues are involved , the ability to rationalise ranges and determine if range(a) is within or overlapping range(b) has been explored in that node. Thankyou all for your input.
However I was not particularly clear about the method of rendering down HMSF (Hour,Min,Sec,Frame) into a common integer that can then be applied to various range operations. Examining my half-baked HMSF->int(Frames) conversion and the irritation afforded me by 30,24,25 frames per second. I began wondering about a way of defining 'arbitary' relationships between an atomic and it's super-representations (you say 750 frames, I say 30 seconds at 25fps). This turned out to be simpler to achieve than I thought, so I ask the Monks - a simpler way?
#!/usr/bin/perl -w use strict; package counter; use Data::Dumper; our %ratio; sub new { my $self = shift; my %data = @_; my $atomic; foreach ( keys %data ) { my $val = $ratio{$_} * $data{$_}; $atomic += $val; } return bless \$atomic , $self; } sub config { my $self = shift; my %cfg = @_; $ratio{$cfg{atomic}}=1; my $key = $cfg{atomic}; while ($key) { my $r = $cfg{$key}->[0]; my $v = $cfg{$key}->[1]; last unless $r; $ratio{$r} = $v * $ratio{$key}; $key = $r; } print Dumper %ratio; } package main; use Data::Dumper; my %pal = ( days=>[], hours=>[ days=>24 ], minutes=>[ hours=>60 ], seconds=>[ minutes=>60 ], frames=>[ seconds=>25], atomic=>'frames', ); my %ntsc = %pal; $ntsc{frames}=[seconds=>30]; my %film = %pal; $film{frames}=[seconds=>24]; my %data = ( days=>0, hours=>0, minutes=>2, seconds=>0, frames=>5, ); counter->config( %pal ); print "In PAL frames " , ${counter->new( %data )}, $/; counter->config( %ntsc ); print "In NTSC frames " , ${counter->new( %data )}, $/; counter->config( %film ); print "In Film frames " , ${counter->new( %data )}, $/;
|
|---|