Image/ExifTool/GM.pm untested

filter: Statementstmt 0.0% 0 / 209 Branchbran 0.0% 0 / 62 Conditioncond 0.0% 0 / 55 MC/DCmcdc 0.0% 0 / 33 Subroutinesub 0.0% 0 / 13 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 380 CC 32 SCAR 55.1
CC
32
Cov
0%
Process_marl
420.0
Process_mrld
132.0
PrintCSV
6.0
CRAP 247.2
1 #------------------------------------------------------------------------------
2 # File: GM.pm
3 #
4 # Description: Read GM PDR metadata from automobile videos
5 #
6 # Revisions: 2024-04-01 - P. Harvey Created
7 #
8 # References: 1) https://exiftool.org/forum/index.php?topic=11335
9 #------------------------------------------------------------------------------
10  
11 package Image::ExifTool::GM;
12  
13 use strict;
14 use vars qw($VERSION);
15 use Image::ExifTool qw(:DataAccess :Utils);
16 use Image::ExifTool::GPS;
17  
18 $VERSION = '1.03';
19  
20 sub Process_marl($$$);
21 sub Process_mrld($$$);
22 sub Process_mrlv($$$);
23 sub PrintCSV($;$);
24  
25 # rename some units strings
26 my %convertUnits = (
27 "\xc2\xb0" => 'deg',
28 "\xc2\xb0C" => 'C',
29 "\xc2\xb0/sec" => 'deg/sec',
30 ltr => 'L',
31 );
32  
33 my $pi = 3.141592653589793;
34  
35 # offsets and scaling factors to convert to reasonable units
36 my %changeOffset = (
37 C => -273.15, # K to C
38 );
39 my %changeScale = (
40 G => 1 / 9.80665, # m/s2 to G
41 kph => 3.6, # m/s to km/h
42 deg => 180 / $pi, # radians to degrees
43 'deg/sec' => 180 / $pi, # rad/s to deg/s
44 '%' => 100, # decimal to %
45 kPa => 1/1000, # Pa to kPa
46 rpm => 10, # ? (arbitrary factor of 10)
47 km => 1/1000, # m to km
48 L => 1000, # m3 to L
49 mm => 1000, # m to mm
50 );
51  
52 # default print conversions for various types of units
53 my %printConv = (
54 rpm => 'sprintf("%.2f rpm", $val)',
55 '%' => 'sprintf("%.2f %%", $val)',
56 kPa => 'sprintf("%.2f kPa", $val)',
57 G => 'sprintf("%.3f G", $val)',
58 km => 'sprintf("%.3f km", $val)',
59 kph => 'sprintf("%.2f km/h", $val)',
60 deg => 'sprintf("%.2f deg", $val)',
61 'deg/sec' => 'sprintf("%.2f deg/sec", $val)',
62 );
63  
64 # channel parameters extracted from marl dictionary
65 my @channel = qw(
66 ID Type Num Units Flags Interval Min Max DispMin DispMax Multiplier Offset
67 Name Description
68 );
69 my %channelStruct = (
70 STRUCT_NAME => 'GM Channel',
71 NOTES => 'Information stored for each channel in the Marlin dictionary.',
72 SORT_ORDER => \@channel,
73 ID => { Writable => 0, Notes => 'channel ID number' },
74 Type => { Writable => 0, Notes => 'measurement type' },
75 Num => { Writable => 0, Notes => 'units ID number' },
76 Units => { Writable => 0, Notes => 'units string' },
77 Flags => { Writable => 0, Notes => 'channel flags' },
78 Interval=> { Writable => 0, Notes => 'measurement interval', ValueConv => '$val / 1e7', PrintConv => '"$val s"' },
79 Min => { Writable => 0, Notes => 'raw value minimum' },
80 Max => { Writable => 0, Notes => 'raw value maximum' },
81 DispMin => { Writable => 0, Notes => 'displayed value minimum' },
82 DispMax => { Writable => 0, Notes => 'displayed value maximum' },
83 Multiplier=>{Writable => 0, Notes => 'multiplier for raw value' },
84 Offset => { Writable => 0, Notes => 'offset for scaled value' },
85 Name => { Writable => 0, Notes => 'channel name' },
86 Description=>{Writable=> 0, Notes => 'channel description' },
87 );
88  
89 # tags found in the 'mrlh' (marl header) atom
90 %Image::ExifTool::GM::mrlh = (
91 PROCESS_PROC => \&Image::ExifTool::ProcessBinaryData,
92 NOTES => 'The Marlin PDR header.',
93 0 => { Name => 'MarlinDataVersion', Format => 'int16u[2]', PrintConv => '$val =~ tr/ /./; $val' },
94 );
95  
96 # tags found in the 'mrlv' (Marlin values) atom
97 %Image::ExifTool::GM::mrlv = (
98 PROCESS_PROC => \&Process_mrlv,
99 FORMAT => 'string',
100 NOTES => q{Tags found in the 'mrlv' (Marlin values) box.},
101 'time'=> { Name => 'Time1', Groups => { 2 => 'Time' }, ValueConv => '$val =~ tr/-/:/; $val' },
102 date => { Name => 'Date1', Groups => { 2 => 'Time' }, ValueConv => '$val =~ tr/-/:/; $val' },
103 ltim => { Name => 'Time2', Groups => { 2 => 'Time' }, ValueConv => '$val =~ tr/-/:/; $val' },
104 ldat => { Name => 'Date2', Groups => { 2 => 'Time' }, ValueConv => '$val =~ tr/-/:/; $val' },
105 tstm => {
106 Name => 'StartTime',
107 Groups => { 2 => 'Time' },
108 Format => 'int64u',
109 RawConv => '$$self{GMStartTime} = $val / 1e7',
110 ValueConv => 'ConvertUnixTime($val, undef, 6)', # (likely UTC, but not sure so don't add time zone)
111 PrintConv => '$self->ConvertDateTime($val)',
112 },
113 zone => { Name => 'TimeZone', Groups => { 2 => 'Time' } },
114 lang => 'Language',
115 unit => { Name => 'Units', PrintConv => { usim => 'U.S. Imperial' } },
116 swvs => 'SoftwareVersion',
117 # id ? ""
118 # cntr ? ""
119 # flap ? ""
120 );
121  
122 # tags found in the 'mrld' (Marlin dictionary) atom
123 %Image::ExifTool::GM::mrld = (
124 PROCESS_PROC => \&Process_mrld,
125 VARS => { ADD_FLATTENED => 1 },
126 WRITABLE => 0,
127 NOTES => q{
128 The Marlin dictionary. Only one channel is listed but all available
129 channels are extracted. Use the -struct (L<API Struct|../ExifTool.html#Struct>) option to extract the
130 channel information as structures.
131 },
132 Channel01 => { Struct => \%channelStruct },
133 );
134  
135 # tags found in 'marl' ctbx timed metadata
136 %Image::ExifTool::GM::marl = (
137 PROCESS_PROC => \&Process_marl,
138 GROUPS => { 2 => 'Other' },
139 VARS => { ID_FMT => 'none', NO_LOOKUP => 1 },
140 NOTES => q{
141 Tags extracted from the 'ctbx' 'marl' (Marlin) box of timed PDR metadata
142 from GM cars. Use the -ee (L<API ExtractEmbedded|../ExifTool.html#ExtractEmbedded>) option to extract this
143 information, or the L<API PrintCSV|../ExifTool.html#PrintCSV> option to output in CSV format.
144 },
145 TimeStamp => { # (the marl timestamp)
146 Groups => { 2 => 'Time' },
147 Notes => q{
148 the numerical value is seconds since start of video, but the print
149 conversion adds StartTime to provide a date/time value. Extracted as
150 GPSDateTime if requested
151 },
152 ValueConv => '$val / 1e7',
153 PrintConv => q{
154 return "$val s" unless $$self{GMStartTime};
155 return $self->ConvertDateTime(ConvertUnixTime($val+$$self{GMStartTime},undef,6));
156 },
157 },
158 GPSDateTime => { # (alternative for TimeStamp)
159 Groups => { 2 => 'Time' },
160 Notes => 'generated from the TimeStamp only if specifically requested',
161 RawConv => '$$self{GMStartTime} ? $val : undef',
162 ValueConv => 'ConvertUnixTime($val / 1e7 + $$self{GMStartTime}) . "Z"',
163 PrintConv => '$self->ConvertDateTime($val,undef,6)',
164 },
165 Latitude => {
166 Name => 'GPSLatitude',
167 Description => 'GPS Latitude', # (need description so we don't set it from the mrld)
168 Groups => { 2 => 'Location' },
169 PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "N")',
170 },
171 Longitude => {
172 Name => 'GPSLongitude',
173 Description => 'GPS Longitude',
174 Groups => { 2 => 'Location' },
175 PrintConv => 'Image::ExifTool::GPS::ToDMS($self, $val, 1, "E")',
176 },
177 Altitude => {
178 Name => 'GPSAltitude',
179 Description => 'GPS Altitude',
180 Groups => { 2 => 'Location' },
181 },
182 Heading => {
183 Name => 'GPSTrack',
184 Description => 'GPS Track',
185 Groups => { 2 => 'Location' },
186 PrintConv => '$val > 360 ? "n/a" : sprintf("%.2f",$val)', # (seen 655.35)
187 },
188 ABSActive => { },
189 AccelPos => { },
190 BatteryVoltage => { },
191 Beacon => { },
192 BoostPressureInd => { },
193 BrakePos => { },
194 ClutchPos => { },
195 CoolantTemp => { },
196 CornerExitSetting => { },
197 CPUFree => { },
198 CPUIO => { },
199 CPUIRQ => { },
200 CPUSystem => { },
201 CPUUser => { },
202 DiskReadOperations => { },
203 DiskReadRate => { },
204 DiskReadTime => { },
205 DiskWriteOperations => { },
206 DiskWriteRate => { },
207 DiskWriteTime => { },
208 Distance => { },
209 DriverPerformanceMode => { },
210 EngineSpeedRequest => { },
211 EngineTorqureReq => { },
212 FuelCapacity => { },
213 FuelLevel => { },
214 Gear => {
215 Notes => q{
216 in the PrintCSV output, the value for Neutral is set to -1, and Reverse to
217 -100 for compatibility with RaceRender
218 },
219 CSVConv => { 13 => -1, 14 => -100 },
220 PrintConv => { 1=>1, 2=>2, 3=>3, 4=>4, 5=>5, 6=>6, 13=>'N', 14=>'R' }
221 },
222 GPSFix => { },
223 InfotainOpMode => { },
224 IntakeAirTemperature => { },
225 IntakeBoostPressure => { },
226 LateralAcceleration => { },
227 LFTyrePressure => { },
228 LFTyreTemp => { },
229 LongitudinalAcceleration => { },
230 LRTyrePressure => { },
231 LRTyreTemp => { },
232 OilPressure => { },
233 OilTemp => { },
234 OutsideAirTemperature => { },
235 RecordingEventOdometer => { },
236 RFTyrePressure => { },
237 RFTyreTemp => { },
238 RPM => { },
239 RRTyrePressure => { },
240 RRTyreTemp => { },
241 Speed => { Groups => { 2 => 'Location' } },
242 SpeedControlResponse => { },
243 SpeedRequestIntervention => { },
244 Steering1Switch => { },
245 Steering2Switch => { },
246 SteeringAngle => { },
247 SuspensionDisplacementLeftFront => { },
248 SuspensionDisplacementLeftRear => { },
249 SuspensionDisplacementRightFront => { },
250 SuspensionDisplacementRightRear => { },
251 SystemBackupPowerEnabled => { },
252 SystemBackupPowerMode => { },
253 SystemPowerMode => { },
254 TractionControlActive => { },
255 TransOilTemp => { },
256 TransportStorageMode => { },
257 ValetMode => { },
258 VehicleStabilityActive => { },
259 VerticalAcceleration => { },
260 WheelspeedLeftDriven => { },
261 'WheelspeedLeftNon-Driven' => { },
262 WheelspeedRightDriven => { },
263 'WheelspeedRightNon-Driven' => { },
264 YawRate => { },
265 );
266  
267 #------------------------------------------------------------------------------
268 # Print a CSV row
269 # Inputs: 0) ExifTool ref, 1) time stamp
270 sub PrintCSV($;$)
271 {
272 my ($et, $ts) = @_;
273 my $csv = $$et{GMCsv} or return; # get the list of channels with measurements
274 @$csv or return;
275 my $vals = $$et{GMVals};
276 my $gmDict = $$et{GMDictionary};
277 my @items = ('') x scalar(@$gmDict);
278 $items[0] = ($ts || $$et{GMMaxTS}) / 1e7;
279 # fill in scaled measurements for this TimeStamp
280 foreach (@$csv) {
281 my $gmChan = $$gmDict[$_];
282 $items[$_] = $$vals[$_] * $$gmChan{Mult} + $$gmChan{Off};
283 # apply CSV conversion if applicable (ie. Gear)
284 next unless $$gmChan{Conv} and defined $$gmChan{Conv}{$items[$_]};
285 $items[$_] = $$gmChan{Conv}{$items[$_]};
286 }
287 my $out = $$et{OPTIONS}{TextOut};
288 print $out join(',',@items),"\n";
289 @$csv = (); # clear the channel list
290 }
291  
292 #------------------------------------------------------------------------------
293 # Process GM Marlin values ('mrlv' box)
294 # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
295 # Returns: 1 on success
296 sub Process_mrlv($$$)
297 {
298 my ($et, $dirInfo, $tagTablePtr) = @_;
299 my $dataPt = $$dirInfo{DataPt};
300 my $dataPos = $$dirInfo{DataPos};
301 my $dirLen = length $$dataPt;
302 my $pos = 0;
303 # data lengths for known formats
304 my %fmtLen = (
305 strs => 64, lang => 64, strl => 256, 'time' => 32, date => 32,
306 tmzn => 32, tstm => 8, focc => 4, "kvp\0" => 64+256,
307 );
308 $et->VerboseDir('mrlv', undef, $dirLen);
309 while ($pos + 8 <= $dirLen) {
310 my $tag = substr($$dataPt, $pos, 4);
311 my $fmt = substr($$dataPt, $pos + 4, 4);
312 my $len = $fmtLen{$fmt};
313 unless ($len) {
314 ($tag, $fmt) = (PrintableTagID($tag), PrintableTagID($fmt));
315 $et->Warn("Unknown format ($fmt) for tag $tag");
316 last;
317 }
318 $pos + 8 + $len > $dirLen and $et->Warn('Truncated mrlv data'), last;
319 $et->HandleTag($tagTablePtr, $tag, undef,
320 DataPt => $dataPt,
321 DataPos => $dataPos,
322 Start => $pos + 8,
323 Size => $len,
324 );
325 $pos += 8 + $len;
326 }
327 return 1;
328 }
329  
330 #------------------------------------------------------------------------------
331 # Process GM Marlin dictionary ('mrld' box)
332 # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
333 # Returns: 1 on success
334 sub Process_mrld($$$)
335 {
336 my ($et, $dirInfo, $tagTablePtr) = @_;
337 my $dataPt = $$dirInfo{DataPt};
338 my $dataPos = $$dirInfo{DataPos};
339 my $dirLen = length $$dataPt;
340 my $struct = $et->Options('Struct') || 0;
341 my $gmDict = $$et{GMDictionary} = [ ];
342 my $marl = GetTagTable('Image::ExifTool::GM::marl');
343 my ($pos, $item, $csv);
344  
345 $et->VerboseDir('mrld', undef, $dirLen);
346 require 'Image/ExifTool/XMPStruct.pl';
347 Image::ExifTool::XMP::AddFlattenedTags($tagTablePtr, undef, undef, 1);
348 $csv = [ ] if $et->Options('PrintCSV');
349  
350 for ($pos=0; $pos+448<=$dirLen; $pos+=448) {
351 # unpack 448-byte records:
352 # 0. int32u - channel number
353 # 1. int32u - measurement type
354 # 2. int32u - units number
355 # 3. string[64] - units string
356 # 4. int32u - flags (0.visible, 1.linear conversion, 2.interpolation OK)
357 # 5. int64u - interval
358 # 6. int32s - min reading
359 # 7. int32s - max reading
360 # 8. double - disp min
361 # 9. double - disp max
362 # 10. double - multiplier
363 # 11. double - offset
364 # 12. string[64] - channel name
365 # 13. string[64] - channel description
366 my @a = unpack("x${pos}NNNZ64Na8N2a8a8a8a8Z64Z64", $$dataPt);
367 my $units = $convertUnits{$a[3]} || $a[3];
368 $a[3] = $et->Decode($a[3], 'UTF8'); # convert from UTF8
369 $_ & 0x8000000 and $_ -= 4294967296 foreach @a[6,7]; # convert signed ints
370 map { $_ = GetDouble(\$_,0) } @a[8,9,10,11]; # convert doubles
371 $a[5] = Get64u(\$a[5],0); # convert 64-bit int
372 my $chan = $a[0];
373 my $tag = sprintf('Channel%.2d', $chan);
374 my $tagInfo = $$tagTablePtr{$tag};
375 my $hash = { map { $channel[$_] => $a[$_] } 1..$#a };
376 unless ($tagInfo) {
377 $tagInfo = AddTagToTable($tagTablePtr, $tag, { Name => $tag, Struct => \%channelStruct });
378 Image::ExifTool::XMP::AddFlattenedTags($tagTablePtr, $tag, undef, 1);
379 }
380 # extract channel structure if specified
381 if ($struct) {
382 $$hash{_ordered_keys_} = [ @channel[1..$#channel] ];
383 $et->FoundTag($tagInfo, $hash);
384 }
385 # extract flattened channel elements
386 if ($struct == 0 or $struct == 2) {
387 $et->HandleTag($tagTablePtr, "$tag$channel[$_]", $a[$_]) foreach 1..$#a;
388 }
389 # add corresponding tag to marl table
390 my $name = Image::ExifTool::MakeTagName($a[12]);
391 $tagInfo = $$marl{$name};
392 unless ($tagInfo) {
393 $et->VPrint(0, $$et{INDENT}, "[adding $name]\n");
394 $tagInfo = AddTagToTable($marl, $name, { });
395 }
396 $$tagInfo{Description} = $a[13] unless $$tagInfo{Description};
397 unless ($$tagInfo{PrintConv}) {
398 # add a default print conversion
399 $$tagInfo{PrintConv} = $printConv{$units} || qq("\$val \Q$units\E");
400 }
401 # adjust multiplier/offset as necessary to scale to more appropriate units
402 # (ie. to the units actually specified in this dictionary -- d'oh)
403 my $mult = $a[10] * ($changeScale{$units} || 1);
404 my $off = $a[11] * ($changeScale{$units} || 1) + ($changeOffset{$units} || 0);
405 my $init = int(($a[6] + $a[7]) / 2); # initial value for difference readings
406 # save information about this channel necessary for processing the marl data
407 $$gmDict[$chan] = { Name => $name, Mult => $mult, Off => $off, Init => $init };
408 $$gmDict[$chan]{Conv} = $$tagInfo{CSVConv};
409 $csv and $$csv[$chan] = $a[12] . ($a[3] ? " ($a[3])" : '');
410 }
411 # channel 0 must not be defined because we use it for the TimeStamp
412 if (defined $$gmDict[0]) {
413 $et->Warn('Internal error: PDR channel 0 is used');
414 delete $$et{GMDictionary};
415 } elsif ($csv) {
416 $$csv[0] = 'Time (s)';
417 defined $_ or $_ = '' foreach @$csv;
418 my $out = $$et{OPTIONS}{TextOut};
419 print $out join(',',@$csv),"\n";
420 $$et{GMCsv} = [ ];
421 }
422 $et->AddCleanup(\&PrintCSV); # print last CSV line when we are done
423 # initialize variables for processing marl box
424 $$et{GMVals} = [ ];
425 $$et{GMMaxTS} = 0;
426 $$et{GMBadChan} = 0;
427 return 1;
428 }
429  
430 #------------------------------------------------------------------------------
431 # Process GM 'marl' ctbx data (ref PH)
432 # Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
433 # Returns: 1 on success
434 # (see https://exiftool.org/forum/index.php?topic=11335.msg61393#msg61393)
435 sub Process_marl($$$)
436 {
437 my ($et, $dirInfo, $tagTablePtr) = @_;
438 my $dataPt = $$dirInfo{DataPt};
439 my $dataPos = ($$dirInfo{DataPos} || 0) + ($$dirInfo{Base} || 0);
440 my $dataLen = length $$dataPt;
441 my $vals = $$et{GMVals}; # running values for each channel (0=TimeStamp)
442 my $chan = $$et{GMChan}; # running channel number
443 my $gmDict = $$et{GMDictionary};
444 my $csv = $$et{GMCsv};
445 my $maxTS = $$et{GMMaxTS};
446 my $reqGPSDateTime = $$et{REQ_TAG_LOOKUP}{gpsdatetime};
447 my $reqTimeStamp = $reqGPSDateTime ? $$et{REQ_TAG_LOOKUP}{timestamp} : 1;
448 my ($pos, $verbose2);
449  
450 $et->VerboseDir('marl', undef, $dataLen);
451 $gmDict or $et->Warn('Missing marl dictionary'), return 0;
452 my $maxChan = $#$gmDict;
453 $verbose2 = 1 if $et->Options('Verbose') > 1;
454 $$vals[0] = -1 unless defined $$vals[0]; # (we use the 0th channel for the TimeStamp)
455 my $ts = $$vals[0];
456  
457 for ($pos=0; $pos + 8 <= $dataLen; $pos += 8) {
458 my @a = unpack("x${pos}NN", $$dataPt);
459 my $ah = $a[0] >> 24;
460 my $a2 = $ah & 0xc0;
461 my ($val, $chanDiff, $valDiff, @ts, $gmChan);
462 if ($a2 == 0xc0) { # 16-byte full record?
463 last if $ah == 0xff; # exit at first empty record
464 $chan = $a[0] & 0x0fffffff;
465 $gmChan = $$gmDict[$chan] or next; # (shouldn't happen)
466 $val = $a[1] - ($a[1] & 0x80000000 ? 4294967296 : 0);
467 $$vals[$chan] = $val;
468 last if $pos + 16 > $dataLen; # (shouldn't happen)
469 $pos += 8; # point at time stamp
470 @ts = unpack("x${pos}NN", $$dataPt);
471 $ts = $ts[0] * 4294967296 + $ts[1];
472 } elsif ($a2 == 0x40) { # 8-byte difference record?
473 next unless defined $chan; # (shouldn't happen)
474 $ts += $a[1]; # increment time stamp
475 $chanDiff = ($ah & 0x3f) - ($ah & 0x20 ? 0x40 : 0);
476 $chan += $chanDiff; # increment the running channel number
477 $gmChan = $$gmDict[$chan] or next; # (shouldn't happen)
478 defined $$vals[$chan] or $$vals[$chan] = $$gmChan{Init}; # init if necessary
479 $valDiff = ($a[0] & 0x00ffffff) - ($a[0] & 0x00800000 ? 0x01000000 : 0);
480 $val = ($$vals[$chan] += $valDiff); # increment the running value for this channel
481 } else {
482 next; # (shouldn't happen)
483 }
484 # ensure that the timestamps are monotonically increasing
485 # (have seen backward steps up to 0.033 sec, so fudge these)
486 if ($ts > $maxTS) {
487 if ($csv) {
488 PrintCSV($et, $maxTS);
489 } else {
490 $$et{DOC_NUM} = ++$$et{DOC_COUNT};
491 $et->HandleTag($tagTablePtr, TimeStamp => $ts) if $reqTimeStamp;
492 $et->HandleTag($tagTablePtr, GPSDateTime => $ts) if $reqGPSDateTime;
493 }
494 $maxTS = $ts;
495 }
496 $csv and push(@$csv, $chan), next;
497 my $scaled = $val * $$gmChan{Mult} + $$gmChan{Off};
498 $et->HandleTag($tagTablePtr, $$gmChan{Name}, $scaled);
499 if ($verbose2) {
500 my $str = " * $$gmChan{Mult} + $$gmChan{Off} = $scaled";
501 my $p0 = $dataPos + $pos - ($a2 == 0xc0 ? 8 : 0);
502 my ($cd,$vd) = @ts ? ('','') : (sprintf('%+d',$chanDiff),sprintf('%+d',$valDiff));
503 printf "| %8.4x: %.8x %.8x chan$cd=%.2d $$gmChan{Name}$vd = $val$str\n", $p0, @a, $chan;
504 printf("| %8.4x: %.8x %.8x TimeStamp = %.6f sec\n", $dataPos + $pos, @ts, $ts / 1e7) if @ts;
505 }
506 }
507 $$vals[0] = $ts; # save last timestamp
508 $$et{GMChan} = $chan; # save last channel number
509 $$et{GMMaxTS} = $ts;
510 delete $$et{DOC_NUM};
511 return 1;
512 }
513  
514 1; # end
515  
516 __END__