1 #include "fpschanger.hpp"
3 fpschanger::fpschanger(uint32_t _tfps_n
, uint32_t _tfps_d
, uint32_t sfps_n
, uint32_t sfps_d
)
5 if(!_tfps_n
|| !_tfps_d
) {
9 if(!sfps_n
|| !sfps_d
) {
15 increment
= static_cast<uint64_t>(tfps_n
) * sfps_d
;
16 decrement
= static_cast<uint64_t>(tfps_d
) * sfps_n
;
20 void fpschanger::change_source_rate(uint32_t sfps_n
, uint32_t sfps_d
)
22 if(!sfps_n
|| !sfps_d
) {
26 uint64_t old_increment
= increment
;
27 increment
= static_cast<uint64_t>(tfps_n
) * sfps_d
;
28 decrement
= static_cast<uint64_t>(tfps_d
) * sfps_n
;
29 //We have to adjust balance by ratio of new and old incrments.
30 balance
= 1.0 * increment
/ old_increment
* balance
+ 0.5;
33 uint64_t fpschanger::duration(uint64_t sduration
)
36 //FIXME: Do this faster.
37 for(uint64_t i
= 0; i
< sduration
; i
++) {