[mythtv-commits] Ticket #12973: Repeated use of time stretch adjustment has rounding error
MythTV
noreply at mythtv.org
Thu Nov 21 11:13:27 UTC 2019
#12973: Repeated use of time stretch adjustment has rounding error
------------------------------+-------------------------------
Reporter: amb@… | Owner: Klaas de Waal
Type: Patch - Bug Fix | Status: assigned
Priority: minor | Milestone: 31.0
Component: MythTV - General | Version: 0.28.0
Severity: low | Resolution:
Keywords: | Ticket locked: 0
------------------------------+-------------------------------
Comment (by Klaas de Waal):
The problem has been reproduced on today's master.
The fix as given, with minor modifications to avoid compiler warnings,
does remove the floating point error accumulation inherent in repeated
additions and subtractions.
The fix as tested is here:
{{{
ctx->m_tsNormal = 0.05*(int)(new_ts_normal * 20.0F + 0.5F);
}}}
However, this does still not guarantee that the displayed value is limited
to two decimal places. This can be specified in the QString::number
conversion that is used to generate the string for presentation, as
applied in the actual code here:
{{{
UpdateOSDStatus(ctx, tr("Adjust Time Stretch"), tr("Time
Stretch"),
QString::number(ctx->m_tsNormal,'f',2),
kOSDFunctionalType_TimeStretchAdjust, "X",
(int)(ctx->m_tsNormal*(1000/kTimeStretchMax)),
kOSDTimeout_None);
}}}
An additional benefit of having always two decimal places is that the
"Time Stretch..."
portion of the message "Adjust Time Stretch....Time Stretch 1.10X"
presentation has a stable position on the screen because of the fixed
length of the string.
--
Ticket URL: <https://code.mythtv.org/trac/ticket/12973#comment:7>
MythTV <http://www.mythtv.org>
MythTV Media Center
More information about the mythtv-commits
mailing list