Skip to content

Commit

Permalink
# ver. 0.9.3.7
Browse files Browse the repository at this point in the history
* bugfix: zero anchor is written even subtitles start from frame 0
  • Loading branch information
subelf committed May 6, 2016
1 parent d7226e9 commit 743f74d
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
Binary file modified Spp2Pgs/res/Spp2Pgs.rc
Binary file not shown.
Binary file modified Spp2PgsNet/res/app.rc
Binary file not shown.
2 changes: 1 addition & 1 deletion libspp2pgs/inc/PgsWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace spp2pgs
static int const MinPtsIntervalTable[];

int const minInterval;
double const clockPerFrame;
double const clocksPerFrame;

Size videoSize;
BdViFrameRate frameRate;
Expand Down
4 changes: 2 additions & 2 deletions libspp2pgs/inc/S2PGlobal.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ namespace spp2pgs
inline double GetFrameRate() const { return framesPerUnit /(double) secondsPerUnit; }
};

int const ClockPerSecond = 90000uL;
int const ClocksPerSecond = 90000uL;
FrameRateInfo const FrameRateTable[] = {
{ 0, 1000 }, { 24000, 1001 }, { 24000, 1000 },
{ 25000, 1000 }, { 30000, 1001 }, { 30000, 1000 },
Expand Down Expand Up @@ -132,7 +132,7 @@ namespace spp2pgs
auto const& frameRateInfo = FrameRateTable[(int)rate];
__int64 const& frames = index;
int const& kFramesPerUnit = frameRateInfo.framesPerUnit / 1000;
int const& kClocksPerSecond = ClockPerSecond / 1000;
int const& kClocksPerSecond = ClocksPerSecond / 1000;
int const& secondsPerUnit = frameRateInfo.secondsPerUnit;

return frames * kClocksPerSecond * secondsPerUnit / kFramesPerUnit;
Expand Down
Binary file modified libspp2pgs/res/libspp2pgs.rc
Binary file not shown.
16 changes: 8 additions & 8 deletions libspp2pgs/src/PgsWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace spp2pgs
PgsWriter::PgsWriter(S2PContext const *context, Size videoSize, BdViFrameRate frameRate, StreamEx* output, __int64 syncPTS) :
S2PControllerBase(context), videoSize(videoSize), frameRate(frameRate), output(output),
isZeroAnchorNeeded(context->Settings()->IsForcingEpochZeroStart()), ptsZeroAnchor(syncPTS),
clockPerFrame(spp2pgs::ClockPerSecond / spp2pgs::GetFramePerSecond(frameRate)),
clocksPerFrame(spp2pgs::ClocksPerSecond / spp2pgs::GetFramePerSecond(frameRate)),
compositionCount(0), isEpochStart(true), minInterval(MinPtsIntervalTable[(int)frameRate]), lastDecEnd(LLONG_MIN),
lastCmpn({ LLONG_MIN, LLONG_MIN, nullptr, nullptr, 0, nullptr })
{
Expand Down Expand Up @@ -81,6 +81,8 @@ namespace spp2pgs
{
pts = ptsZeroAnchor;
}

isZeroAnchorNeeded = false;
}

__int64 dts = pts - decDur;
Expand All @@ -101,7 +103,7 @@ namespace spp2pgs
}
}

if (!isEpochStart && pts > lastCmpn.ets + clockPerFrame)
if (!isEpochStart && pts > lastCmpn.ets + clocksPerFrame)
{
this->TryInsertEraserBefore(dts);
}
Expand Down Expand Up @@ -181,9 +183,9 @@ namespace spp2pgs

if (!this->Settings()->IsForcingTmtCompat())
{
double const & minIntervalFramed = ceil(eraseDuration / clockPerFrame) * clockPerFrame;
double const & minIntervalFramed = ceil(eraseDuration / clocksPerFrame) * clocksPerFrame;
double const & lastPosibleEts = max(ets, lastCmpn.pts + minIntervalFramed); //reserve time for erasing
int const &lastPosibleEtsFrame = (int)(round(lastPosibleEts / clockPerFrame));
int const &lastPosibleEtsFrame = (int)(round(lastPosibleEts / clocksPerFrame));
pts = spp2pgs::GetFrameTimeStamp(lastPosibleEtsFrame, frameRate); //update ets to a reasonable value
}

Expand All @@ -204,7 +206,7 @@ namespace spp2pgs

void PgsWriter::IgnoreComposition(__int64 pts, __int64 ets)
{
if (!isEpochStart && pts > lastCmpn.ets + clockPerFrame)
if (!isEpochStart && pts > lastCmpn.ets + clocksPerFrame)
{
this->TryInsertEraserBefore(pts);
}
Expand All @@ -218,7 +220,7 @@ namespace spp2pgs
{
int eraseDuration = wndDesc->EstimateDecodeDuration();

double const & minIntervalFramed = ceil(eraseDuration / clockPerFrame) * clockPerFrame;
double const & minIntervalFramed = ceil(eraseDuration / clocksPerFrame) * clocksPerFrame;
double const & lastPosibleEts = max(lastCmpn.ets, lastCmpn.pts + minIntervalFramed);

if (dts > lastPosibleEts + minIntervalFramed)
Expand Down Expand Up @@ -451,8 +453,6 @@ namespace spp2pgs
this->EndEpoch();

this->StartEpoch(tCurWnd);

this->isZeroAnchorNeeded = false;
}

}

0 comments on commit 743f74d

Please sign in to comment.