mirror of
https://github.com/WiVRn/WiVRn.git
synced 2026-11-28 04:46:55 -08:00
Add IDR info in timings csv
This commit is contained in:
1 parent
df786362e7
commit
7e22b3fa92
4 files changed
+25
-13
No files matched your search
@@ -92,7 +92,9 @@ void VideoEncoder::Encode(wivrn_session & cnx,
|
||||
{
|
||||
this->cnx = &cnx;
|
||||
auto target_timestamp = std::chrono::steady_clock::time_point(std::chrono::nanoseconds(view_info.display_time));
|
||||
cnx.dump_time("encode_begin", frame_index, os_monotonic_get_ns(), stream_idx);
|
||||
bool idr = sync_needed.exchange(false);
|
||||
const char* extra = idr ? ",idr" : ",p";
|
||||
cnx.dump_time("encode_begin", frame_index, os_monotonic_get_ns(), stream_idx, extra);
|
||||
|
||||
// Prepare the video shard template
|
||||
shard.stream_item_idx = stream_idx;
|
||||
@@ -100,8 +102,8 @@ void VideoEncoder::Encode(wivrn_session & cnx,
|
||||
shard.shard_idx = 0;
|
||||
shard.view_info = view_info;
|
||||
|
||||
Encode(index, sync_needed.exchange(false), target_timestamp);
|
||||
cnx.dump_time("encode_end", frame_index, os_monotonic_get_ns(), stream_idx);
|
||||
Encode(index, idr, target_timestamp);
|
||||
cnx.dump_time("encode_end", frame_index, os_monotonic_get_ns(), stream_idx, extra);
|
||||
}
|
||||
|
||||
void VideoEncoder::SendData(std::span<uint8_t> data, bool end_of_frame)
|
||||
|
||||
@@ -277,11 +277,11 @@ std::array<to_headset::video_stream_description::foveation_parameter, 2> wivrn_s
|
||||
return hmd->get_foveation_parameters();
|
||||
}
|
||||
|
||||
void wivrn_session::dump_time(const std::string & event, uint64_t frame, uint64_t time, uint8_t stream)
|
||||
void wivrn_session::dump_time(const std::string & event, uint64_t frame, uint64_t time, uint8_t stream, const char* extra)
|
||||
{
|
||||
if (feedback_csv)
|
||||
{
|
||||
std::lock_guard lock(csv_mutex);
|
||||
feedback_csv << std::quoted(event) << "," << frame << "," << time << "," << (int)stream << std::endl;
|
||||
feedback_csv << std::quoted(event) << "," << frame << "," << time << "," << (int)stream << extra << std::endl;
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
|
||||
std::array<to_headset::video_stream_description::foveation_parameter, 2> get_foveation_parameters();
|
||||
|
||||
void dump_time(const std::string & event, uint64_t frame, uint64_t time, uint8_t stream = -1);
|
||||
void dump_time(const std::string & event, uint64_t frame, uint64_t time, uint8_t stream = -1, const char* extra = "");
|
||||
|
||||
private:
|
||||
static void run(std::weak_ptr<wivrn_session>);
|
||||
|
||||
@@ -13,6 +13,7 @@ class Frame:
|
||||
self.num = num
|
||||
self.events = dict()
|
||||
self.streams = dict()
|
||||
self.flags = dict()
|
||||
|
||||
def set(self, event, timestamp, stream):
|
||||
if stream == 255:
|
||||
@@ -22,7 +23,10 @@ class Frame:
|
||||
self.streams[stream] = dict()
|
||||
self.streams[stream][event] = timestamp
|
||||
|
||||
def duration(self, begin="wake_up", end="display", stream=None):
|
||||
def flag(self, stream, flag):
|
||||
self.flags[stream if stream != 255 else None] = flag
|
||||
|
||||
def duration(self, begin="wake_up", end="display", stream=None, begin_selector=min, end_selector=max):
|
||||
try:
|
||||
if stream is None:
|
||||
streams = list(self.streams.values())
|
||||
@@ -31,13 +35,13 @@ class Frame:
|
||||
if begin in self.events:
|
||||
t0 = self.events[begin]
|
||||
else:
|
||||
t0 = min([s[begin] for s in streams])
|
||||
t0 = begin_selector([s[begin] for s in streams])
|
||||
if end in self.events:
|
||||
t1 = self.events[end]
|
||||
else:
|
||||
t1 = max([s[end] for s in streams])
|
||||
t1 = end_selector([s[end] for s in streams])
|
||||
return (t1 - t0)/1_000_000
|
||||
except KeyError:
|
||||
except (KeyError, ValueError):
|
||||
return None
|
||||
|
||||
|
||||
@@ -138,7 +142,7 @@ def read(file, skip=0, duration_ms=-1):
|
||||
|
||||
origin = None
|
||||
frames = []
|
||||
for event, frame, timestamp, stream in timings:
|
||||
for event, frame, timestamp, stream, *extra in timings:
|
||||
frame = int(frame) - skip
|
||||
|
||||
if frame < 0:
|
||||
@@ -161,10 +165,16 @@ def read(file, skip=0, duration_ms=-1):
|
||||
frames.append(Frame(len(frames)))
|
||||
|
||||
frames[frame].set(event, timestamp, stream)
|
||||
for x in extra:
|
||||
frames[frame].flag(stream, x)
|
||||
return frames
|
||||
|
||||
def durations(frames, begin="wake_up", end="display", stream=None):
|
||||
res = [frame.duration(begin, end, stream) for frame in frames]
|
||||
def durations(frames, stream=None, flag=None, *args, **kwargs):
|
||||
def filter(frame):
|
||||
if flag is None:
|
||||
return True
|
||||
return flag in frame.flags.get(stream, ())
|
||||
res = [frame.duration(*args, **kwargs) for frame in frames if filter(frame)]
|
||||
return [d for d in res if d is not None]
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user