| 877 | | for (int i = 0; i < lastFrames.size(); i++) { |
|---|
| 878 | | // all the frames in the vector should have the same timecode at the moment |
|---|
| 879 | | TimeValue64 duration = block.GlobalTimecode() / timecodeScale - lastFrames[i].pts; |
|---|
| 880 | | |
|---|
| 881 | | // since there can be multiple frames in one block, split the duration evenly between them |
|---|
| 882 | | // giving the remainder to the latter blocks |
|---|
| 883 | | int remainder = duration % lastFrames.size() >= lastFrames.size() - i ? 1 : 0; |
|---|
| 884 | | |
|---|
| 885 | | lastFrames[i].duration = duration / lastFrames.size() + remainder; |
|---|
| 886 | | |
|---|
| 887 | | AddFrame(lastFrames[i]); |
|---|
| 888 | | } |
|---|
| 889 | | lastFrames.clear(); |
|---|
| | 877 | // don't add the blocks until we get one with a new timecode |
|---|
| | 878 | TimeValue64 duration = 0; |
|---|
| | 879 | if (lastFrames.size() > 0) |
|---|
| | 880 | duration = block.GlobalTimecode() / timecodeScale - lastFrames[0].pts; |
|---|
| | 881 | |
|---|
| | 882 | if (duration > 0) { |
|---|
| | 883 | for (int i = 0; i < lastFrames.size(); i++) { |
|---|
| | 884 | // since there can be multiple frames in one block, split the duration evenly between them |
|---|
| | 885 | // giving the remainder to the latter blocks |
|---|
| | 886 | int remainder = duration % lastFrames.size() >= lastFrames.size() - i ? 1 : 0; |
|---|
| | 887 | |
|---|
| | 888 | lastFrames[i].duration = duration / lastFrames.size() + remainder; |
|---|
| | 889 | |
|---|
| | 890 | AddFrame(lastFrames[i]); |
|---|
| | 891 | } |
|---|
| | 892 | lastFrames.clear(); |
|---|
| | 893 | } |
|---|