| 41 | } |
| 42 | |
| 43 | static size_t GetMaxCountInSameTimeRange( |
| 44 | std::vector<std::pair<pag::TimeRange, size_t>>& timeRangeList, |
| 45 | pag::Frame* startTime = nullptr) { |
| 46 | if (timeRangeList.empty()) { |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | std::vector<std::pair<pag::Frame, size_t>> startTimeList = {}; |
| 51 | std::vector<std::pair<pag::Frame, size_t>> endTimeList = {}; |
| 52 | |
| 53 | for (auto timeRange : timeRangeList) { |
| 54 | startTimeList.emplace_back(timeRange.first.start, timeRange.second); |
| 55 | endTimeList.emplace_back(timeRange.first.end, timeRange.second); |
| 56 | } |
| 57 | |
| 58 | auto timeCompareFunction = [](const std::pair<pag::Frame, size_t> a, |
| 59 | const std::pair<pag::Frame, size_t> b) -> bool { |
| 60 | return a.first < b.first; |
| 61 | }; |
| 62 | |
| 63 | sort(startTimeList.begin(), startTimeList.end(), timeCompareFunction); |
| 64 | sort(endTimeList.begin(), endTimeList.end(), timeCompareFunction); |
| 65 | |
| 66 | size_t startTimeIndex = 0; |
| 67 | size_t endTimeIndex = 0; |
| 68 | size_t maxCount = 0; |
| 69 | size_t count = 0; |
| 70 | pag::Frame maxCountFrame = 0; |
| 71 | while (startTimeIndex < startTimeList.size()) { |
| 72 | if (startTimeList[startTimeIndex].first < endTimeList[endTimeIndex].first) { |
| 73 | count += startTimeList[startTimeIndex].second; |
| 74 | if (maxCount < count) { |
| 75 | maxCount = count; |
| 76 | maxCountFrame = startTimeList[startTimeIndex].first; |
| 77 | } |
| 78 | startTimeIndex++; |
| 79 | } else { |
| 80 | count -= endTimeList[endTimeIndex].second; |
| 81 | endTimeIndex++; |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | if (startTime != nullptr) { |
| 86 | *startTime = maxCountFrame; |
| 87 | } |
| 88 | return maxCount; |
| 89 | } |
| 90 | |
| 91 | static void CheckBitmapAndVideoNum(std::shared_ptr<PAGExportSession> session, |
| 92 | std::vector<pag::Composition*>& compositions, |
no test coverage detected