Hi. On Mon, Nov 21, 2011 at 11:23 PM, Johannes Sixt <[email protected]> wrote: > Am 21.11.2011 19:41, schrieb Einar Rünkaru: >> Linear interoplation is not applicable to on/off switch >> Rounding interpolated blur radius value >> Fix proposed by Michal Fapso <[email protected]> > > BTW, I would very much appreciate if you would include the complete > explanation why this fix is needed in the commit message, including the > symptoms that can be seen without the patch. For example: > > ----- > Do not interpolate on-off-switches for two reasons: > > - It does not make sense. To use the setting of the preceding keyframe > is the only thing that makes sense. > > - When both the previous and the next keyframe have the setting at one, > then the exact result of the numeric computation should be one as > well. However, the sum of prev_scale and next_scale can be slightly > less than one due to floatingpoint rounding. In such a case, the > value is truncated to zero, and causes the blur to be turned off > spuriously, causing flickering video in the interpolated range.
Just the first reason is enough. Thogh for educational purposes the second reason can be added too: floating point calculation is always inexact - it has errors and the errors can show up in very weird places. Ok, i change the commit message. > > Also do not just truncate the interpolated value of the blur radius, > but round it. > > Fix proposed by Michal Fapso <[email protected]> > ------ > > - this->vertical = (int)(prev.vertical * prev_scale + next.vertical * > next_scale); > - this->horizontal = (int)(prev.horizontal * prev_scale + > next.horizontal * next_scale); > - this->radius = (int)(prev.radius * prev_scale + next.radius * > next_scale); > + this->vertical = prev.vertical; > + this->horizontal = prev.horizontal; > + this->radius = round(prev.radius * prev_scale + next.radius * > next_scale); > > Don't you see a warning here? There result of round() is still double > and should require a cast to int. No. There are well defined implict conversions that do not need casts. To improve the readability all unneeded suff must be removed. Casts can be used in places there one wants some non-standard conversion or where is no good default conversion. Float - int - double conversions are well defined. Einar _______________________________________________ Cinelerra mailing list [email protected] https://init.linpro.no/mailman/skolelinux.no/listinfo/cinelerra
