From 0e3c61abed24e2fec2148b22fe204e28074f1e90 Mon Sep 17 00:00:00 2001 From: Mikhail Burakov Date: Sat, 14 Oct 2023 15:31:14 +0200 Subject: Track video frame encoding latency --- encode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'encode.c') diff --git a/encode.c b/encode.c index 1c45e63..9ee7ddd 100644 --- a/encode.c +++ b/encode.c @@ -33,6 +33,7 @@ #include "gpu.h" #include "hevc.h" #include "proto.h" +#include "toolbox/perf.h" #include "toolbox/utils.h" struct EncodeContext { @@ -778,7 +779,8 @@ static bool DrainBuffers(int fd, struct iovec* iovec, int count) { } } -bool EncodeContextEncodeFrame(struct EncodeContext* encode_context, int fd) { +bool EncodeContextEncodeFrame(struct EncodeContext* encode_context, int fd, + unsigned long long timestamp) { bool result = false; VABufferID buffers[8]; VABufferID* buffer_ptr = buffers; @@ -927,7 +929,7 @@ bool EncodeContextEncodeFrame(struct EncodeContext* encode_context, int fd) { .size = segment->size, .type = PROTO_TYPE_VIDEO, .flags = idr ? PROTO_FLAG_KEYFRAME : 0, - .latency = 0, + .latency = (uint16_t)(MicrosNow() - timestamp), }; struct iovec iovec[] = { {.iov_base = &proto, .iov_len = sizeof(proto)}, -- cgit v1.2.3