After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 613064 - Improve class Zoomable: better pixels <--> nanoseconds conversions?
Improve class Zoomable: better pixels <--> nanoseconds conversions?
Status: RESOLVED OBSOLETE
Product: pitivi
Classification: Other
Component: Timeline
Git
Other Linux
: Normal normal
: Git
Assigned To: Pitivi maintainers
Pitivi maintainers
Depends on:
Blocks: 609377
 
 
Reported: 2010-03-16 17:41 UTC by DELETED
Modified: 2015-10-20 13:24 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description DELETED 2010-03-16 17:41:00 UTC
While investigating bug 609377, I found that the two methods

  pitivi.ui.zoominterface.(pixelToNs|nsToPixel)

currently *both* truncate the results in order to return natural numbers, because they calculate with a float ratio. This makes the whole ns <--> pixel conversion blurry.

However, we need a precise way to calculate pixels from nanoseconds and vice versa. Precise means: without random rounding and without any floating point numbers/calculations involved.

Here is a suggestion how to achieve this:

- Use ratio = nanoseconds/pixel instead of the current pixel/second (floating point ratio), and allow *only natural numbers* for ratio. This way the ratios we can use are:
1 ns/px, 2 ns/px, .... this should be more than sufficient.

- Use the following functions for conversations between pixels and ns:

  pixelToNs(px) = px * ratio

  nsToPixel(ns) = ns / ratio [*]

  [*]: '/' means the usual python integer division (4 / 3 = 1)

Notice that using this ratio has the benefits that:
- px, ns and ratio are always *natural numbers*
- pixelToNs() does not need to round its result
Comment 1 Edward Hervey 2010-03-19 09:32:45 UTC
I like it when bugs close themselves :)
Comment 2 DELETED 2010-08-31 16:30:16 UTC
I open this bug again because I think this issue needs to be solved. The current time to pixel conversion simply isn't reliable. It needs to be improved, however this will be done, my suggestion above is just one idea. Does anyone have better proposals?
Comment 3 Thibault Saunier 2015-10-20 13:24:26 UTC
This bug has been migrated to https://phabricator.freedesktop.org/T2502.

Please use the Phabricator interface to report further bugs by creating a task and associating it with Project: Pitivi.

See http://wiki.pitivi.org/wiki/Bug_reporting for details.