GNOME Bugzilla – Bug 613064
Improve class Zoomable: better pixels <--> nanoseconds conversions?
Last modified: 2015-10-20 13:24:26 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
I like it when bugs close themselves :)
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?
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.