MCPcopy Create free account
hub / github.com/NVIDIA/DALI / GetFrameIdxByTimestamp

Method GetFrameIdxByTimestamp

dali/operators/video/frames_decoder_base.h:72–96  ·  view source on GitHub ↗

* @brief Returns the index of the frame that has the given timestamp * * @param timestamp Timestamp of the frame to seek to * @param rounddown If true, the seek will be to a frame that has this timestamp or a previous one */

Source from the content-addressed store, hash-verified

70 * @param rounddown If true, the seek will be to a frame that has this timestamp or a previous one
71 */
72 int GetFrameIdxByTimestamp(int64_t timestamp, bool rounddown = false) const {
73 LOG_LINE << "GetFrameIdxByTimestamp: timestamp=" << timestamp << ", rounddown=" << rounddown
74 << ", index_size=" << index.size() << std::endl;
75 int frame_idx = 0;
76 for (size_t i = 0; i < index.size(); i++) {
77 if (index[i].pts == timestamp) {
78 LOG_LINE << "Exact match found at index " << i << std::endl;
79 frame_idx = i;
80 break;
81 } else if (index[i].pts > timestamp) {
82 LOG_LINE << "Frame " << i << " with pts=" << index[i].pts << " is the first frame past the timestamp" << std::endl;
83 if (rounddown && i > 0) {
84 LOG_LINE << "Round down mode: previous frame " << i - 1 << " with pts=" << index[i - 1].pts << " is the last frame before the timestamp" << std::endl;
85 frame_idx = i - 1;
86 } else {
87 LOG_LINE << "Round up mode: frame " << i << " with pts=" << index[i].pts << " is the first frame past the timestamp" << std::endl;
88 frame_idx = i;
89 }
90 break;
91 }
92 }
93 assert(frame_idx >= 0 && frame_idx < static_cast<int>(index.size()));
94 LOG_LINE << "Returning frame_idx=" << frame_idx << std::endl;
95 return frame_idx;
96 }
97};
98
99/**

Callers 2

GetFrameIdxByTimestampFunction · 0.80
PrepareMetadataImplMethod · 0.80

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected