From: Jan Michel Date: Fri, 2 Aug 2013 16:51:26 +0000 (+0200) Subject: more performance improvements X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=40b038e903d931a6e961cc150a5b3beac5e8a753;p=mvdsensorcontrol.git more performance improvements --- diff --git a/tools/preview/unpack_hld.pl b/tools/preview/unpack_hld.pl index cd1e2e5..f7dffd6 100755 --- a/tools/preview/unpack_hld.pl +++ b/tools/preview/unpack_hld.pl @@ -286,19 +286,28 @@ sub getSubEvtData() { #- Subtract subevent header size and devide by word size my $nrOfWords = ($size - 16)/4; - my $tmp; - my $word; - foreach my $i (1..$nrOfWords){ - read($fh, $tmp, 4); - if($endian){ - $word = unpack("V*", $tmp); # Little Endian - } - else{ - $word = unpack("N*", $tmp); # Big Endian - } - push(@$data_aref, $word); - } + + my @tmps; + read($fh, $tmp, 4*$nrOfWords); + if($endian){ + @$data_aref = unpack("V*",$tmp); + } + else{ + @$data_aref = unpack("N*",$tmp); + } + +# my $word; +# foreach my $i (1..$nrOfWords){ +# read($fh, $tmp, 4); +# if($endian){ +# $word = unpack("V*", $tmp); # Little Endian +# } +# else{ +# $word = unpack("N*", $tmp); # Big Endian +# } +# push(@$data_aref, $word); +# } } sub padding() @@ -377,16 +386,20 @@ sub analyzeData() { my $SensorStatus = $data->[$pos++]; my $SensorError = $data->[$pos++]; my $SensorDebug = $data->[$pos++]; - my $SensorTime = sprintf("%08x%08x",$data->[$pos+1],$data->[$pos]); + + if($opt_frameinfo) { + my $SensorTime = sprintf("%08x%08x",$data->[$pos+1],$data->[$pos]) if $opt_frameinfo; + printf("ID\t%8x\tStatus\t%08x\tError\t%08x\tDebug\t%08x\tTime\t%s\n", + $SensorId, $SensorStatus, $SensorError, $SensorDebug, $SensorTime); + } + $pos+= 2; $PMap->{$SensorId}->[575]->[1151] = 0 unless defined $PMap->{$SensorId}->[575]->[1151]; my $matrix = $PMap->{$SensorId}; - $pos+= 2; + - printf("ID\t%8x\tStatus\t%08x\tError\t%08x\tDebug\t%08x\tTime\t%s\n", - $SensorId, $SensorStatus, $SensorError, $SensorDebug, $SensorTime) if $opt_frameinfo; #Could it be...? if($SensorHead != 0xffffffff) { @@ -421,23 +434,23 @@ sub analyzeData() { while(1) { #Disentangle 16 Bit words if($i=1-$i) {$d = $data->[$pos++] & 0xffff;} - else {$d = ($data->[$pos] >> 16) & 0xffff;} + else {$d = ($data->[$pos] >> 16);} #Is new line? if($statecnt-- == 0) { - $ovf += $d >> 15; + $ovf += ($d >> 15) & 1; $line = ($d >> 4) & 0x7FF; $statecnt = $d & 0xF; } else { - $pixels = ($d & 0x3) + 1; + $pixels = ($d & 0x3); $column = ($d >> 2) & 0x7FF; - printf("\t$line, $column x $pixels\n") if $opt_frameinfo; + printf("\t$line, $column x %d\n",$pixels+1) if $opt_frameinfo; $matrix->[$line]->[$column]++; - $matrix->[$line]->[$column+1]++ if $pixels > 1; - $matrix->[$line]->[$column+2]++ if $pixels > 2; - $matrix->[$line]->[$column+3]++ if $pixels > 3; + $matrix->[$line]->[$column+1]++ if $pixels > 0; + $matrix->[$line]->[$column+2]++ if $pixels > 1; + $matrix->[$line]->[$column+3]++ if $pixels > 2; } last if $pos >= $FrameEndPos; @@ -482,10 +495,11 @@ sub WriteResults { my @matrix; for(my $y = 0; $y < 576; $y++) { + my $map = $PMap->{$id}->[$y]; #Define lengths of all arrays - $PMap->{$id}->[$y]->[1151] = 0 unless defined $PMap->{$id}->[$y]->[1151]; + $map->[1151] = 0 unless defined $map->[1151]; #Fill undef with 0 - @matrix = map {defined $_ ? $_ : 0 } @{$PMap->{$id}->[$y]}; + @matrix = map {defined $_ ? $_ : 0 } @{$map}; #Join lines my $l = join(" ",@matrix); print $fh $l."\n";