Domanda

I am trying to decode a timecode which is using an approximated log curve (see picture). Its not a real log curve, but consist of linear curves.

For example, when the timecode shows 822496, the real time is 2793ms. I have printed the curve, and found the break-points when a new linear curve begins:

Linear approximation of log

milliseconds => timecode
2793ms => 822496
6844ms => 906195
...
510982ms => 1408395

A new linear curve starts about every 83700 timecode-values. Currently I am unsing a real log curve, but I would like to know how to do it with linear curves, to be more precise.

My question is, how can I find the formular to calculate the real time (ms) from my timecode using linear curves as close as possible?

The log function to approximate this curve is (fitting at the break-points):

y = log x * 119900 - 167700
È stato utile?

Soluzione

What language? In Java I'd build a NavigableMap (TreeMap) of timecode -> real time, and then lookup the floorEntry( timecode) to find the nearest entry.

Of course, you'll need to calculate/ empirically determine the correspondence & build the map; either all beforehand, or growing the extents on-demand.

One thing that's unclear about your question.. can you exactly reverse-engineer the timecode calculation, or is this just an approximation & you are going to search for the exact position from there?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top