<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="generator" content="pandoc" />
  <title></title>
  <style type="text/css">code{white-space: pre;}</style>
</head>
<body>
<p>Hi Remi,</p>
<p>On 2016-11-01 15:00, Rémi Denis-Courmont wrote:</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> Le tiistaina 1. marraskuuta 2016, 2.04.06 EET Filip Roséen a écrit :</code></pre>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;color:#500050">
<pre><code> The previous implementation could overflow the mtime_t when
 multiplying p_sys->p_fp->i_preroll by a thousand when converting from
 the asf time unit (milliseconds) to VLCs (microseconds).

 Given that you can always divide a value without running into issues
 in terms of under/overflow, these changes prevent any overflow error
 while still preserving the same logic.

 In short the implementation takes advantage of the below two
 conditions being equivalent:

    1: A > ( ( B * C ) + D )
    2: ( ( A - D ) / C ) > B</code></pre>
</blockquote>
<pre><code> That´s true with reals, not with integers. For instance,
 with A=2, B=0, C=2, D=1:

 (1) <=> 2 > ((0 * 2) + 1 <=> 2 > 1 <=> true
 (2) <=> ((2 - 1) / 2) > 0 <=> (1 / 2) > 0 <=> 0 > 0 <=> false

 (I don´t know if it affects the correctness of the diff.)</code></pre>
</blockquote>
<p>That’s a valid point, and I should have written a constraint on the values of <code>A</code>, <code>B</code>, <code>C</code>.</p>
<p>As far as I can tell the patch should have the same behavior as the previous implementation, though without suffering from a potential integer overflow. Basically all the implementation does is converting from one time unit to another, and changing from multiplying on the right-hand side to dividing on the left-hand side should not make a difference; both methods suffer from loss of precision in one way or another.</p>
<p>Thanks,<br />
Filip</p>
</body>
</html>