Adjust frame number for Clip position and start (which can result in a different number)
| 1095 | |
| 1096 | // Adjust frame number for Clip position and start (which can result in a different number) |
| 1097 | int64_t FrameMapper::AdjustFrameNumber(int64_t clip_frame_number) { |
| 1098 | |
| 1099 | // Get clip position from parent clip (if any) |
| 1100 | float position = 0.0; |
| 1101 | float start = 0.0; |
| 1102 | Clip *parent = static_cast<Clip *>(ParentClip()); |
| 1103 | if (parent) { |
| 1104 | position = parent->Position(); |
| 1105 | start = parent->Start(); |
| 1106 | } |
| 1107 | |
| 1108 | // Adjust start frame and position based on parent clip. |
| 1109 | // This ensures the same frame # is used by mapped readers and clips, |
| 1110 | // when calculating samples per frame. |
| 1111 | // Thus, this prevents gaps and mismatches in # of samples. |
| 1112 | int64_t clip_start_frame = (start * info.fps.ToDouble()) + 1; |
| 1113 | int64_t clip_start_position = round(position * info.fps.ToDouble()) + 1; |
| 1114 | int64_t frame_number = clip_frame_number + clip_start_position - clip_start_frame; |
| 1115 | |
| 1116 | return frame_number; |
| 1117 | } |
| 1118 | |
| 1119 | // Set direction hint for the next call to GetFrame |
| 1120 | void FrameMapper::SetDirectionHint(const bool increasing) |