---------------------------------------------------------------------------
| 714 | |
| 715 | //--------------------------------------------------------------------------- |
| 716 | TimeCode TimeCode::ToRescaled(uint32_t FramesMax, flags Flags, rounding Rounding) const |
| 717 | { |
| 718 | auto Result = ToFrames(); |
| 719 | auto FrameRate = (uint64_t)GetFramesMax() + 1; |
| 720 | if (Is1001fps() != Flags.Is1001fps()) |
| 721 | { |
| 722 | Result *= int64_t(1000 + Is1001fps()); |
| 723 | FrameRate *= int64_t(1000 + Flags.Is1001fps()); |
| 724 | } |
| 725 | Result *= (uint64_t)FramesMax + 1; |
| 726 | switch (Rounding) |
| 727 | { |
| 728 | case Nearest: |
| 729 | Result += FrameRate / 2; |
| 730 | [[fallthrough]]; |
| 731 | case Floor: |
| 732 | Result /= FrameRate; |
| 733 | break; |
| 734 | case Ceil: |
| 735 | { |
| 736 | auto NewResult = Result / FrameRate; |
| 737 | auto NewRemain = Result % FrameRate; |
| 738 | if (NewRemain) |
| 739 | NewResult++; |
| 740 | Result = NewResult; |
| 741 | break; |
| 742 | } |
| 743 | } |
| 744 | return TimeCode(Result, FramesMax, Flags); |
| 745 | } |
| 746 | |
| 747 | //--------------------------------------------------------------------------- |
| 748 | string TimeCode::ToString() const |
no test coverage detected