64 lines
1.6 KiB
PHP
64 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace swf2ass;
|
|
|
|
class FrameInformation {
|
|
private int $frameNumber;
|
|
private int $frameOffset = 0;
|
|
|
|
private float $frameRate;
|
|
|
|
private ?ViewFrame $frame;
|
|
|
|
|
|
public function __construct(int $frameNumber, float $frameRate, ?ViewFrame $frame) {
|
|
$this->frameNumber = $frameNumber;
|
|
$this->frameRate = $frameRate;
|
|
$this->frame = $frame;
|
|
}
|
|
|
|
public function setFrameOffset(int $frameOffset) {
|
|
$this->frameOffset = $frameOffset;
|
|
}
|
|
|
|
public function getFrameOffset(): int {
|
|
return $this->frameOffset;
|
|
}
|
|
|
|
public function getFrame(): ?ViewFrame {
|
|
return $this->frame;
|
|
}
|
|
|
|
public function getFrameNumber(): int {
|
|
return $this->frameNumber - $this->frameOffset;
|
|
}
|
|
|
|
public function getStartTimeSeconds(): float {
|
|
return $this->getFrameNumber() / $this->frameRate;
|
|
}
|
|
|
|
public function getStartTimeMilliSeconds(): float {
|
|
return $this->getStartTimeSeconds() * 1000;
|
|
}
|
|
|
|
public function getEndTimeSeconds(): float {
|
|
return $this->getStartTimeSeconds() + $this->getFrameDurationSeconds();
|
|
}
|
|
|
|
public function getEndTimeMilliSeconds(): float {
|
|
return $this->getEndTimeSeconds() * 1000;
|
|
}
|
|
|
|
public function getFrameDurationSeconds(): float {
|
|
return 1 / $this->frameRate;
|
|
}
|
|
|
|
public function getFrameDurationMilliSeconds(): float {
|
|
return $this->getFrameDurationSeconds() * 1000;
|
|
}
|
|
|
|
|
|
public function diff(FrameInformation $other): FrameInformation {
|
|
return new FrameInformation($this->getFrameNumber() - $other->getFrameNumber(), $this->frameRate, null);
|
|
}
|
|
} |