From facbf05608f80b322e3da5f5b8352d289b6fbc89 Mon Sep 17 00:00:00 2001 From: Martin Pulec Date: Tue, 2 Aug 2022 11:24:59 +0200 Subject: [PATCH] lavc: increment pts directly, do not use static var Since the in_frame is recycled, there is no need to store sequential number separately. --- src/video_compress/libavcodec.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video_compress/libavcodec.cpp b/src/video_compress/libavcodec.cpp index 68832ba59..a0b9cfe77 100644 --- a/src/video_compress/libavcodec.cpp +++ b/src/video_compress/libavcodec.cpp @@ -1281,6 +1281,7 @@ static bool configure_with(struct state_video_compress_libav *s, struct video_de log_msg(LOG_LEVEL_ERROR, "Could not allocate video frame\n"); return false; } + s->in_frame->pts = -1; AVPixelFormat fmt = (s->hwenc) ? AV_PIX_FMT_NV12 : s->selected_pixfmt; #if LIBAVCODEC_VERSION_MAJOR >= 53 @@ -1363,7 +1364,6 @@ static void *pixfmt_conv_task(void *arg) { static shared_ptr libavcodec_compress_tile(struct module *mod, shared_ptr tx) { struct state_video_compress_libav *s = (struct state_video_compress_libav *) mod->priv_data; - static int frame_seq = 0; unsigned char *decoded; shared_ptr out{}; list> cleanup_callbacks; // at function exit handlers @@ -1410,7 +1410,7 @@ static shared_ptr libavcodec_compress_tile(struct module *mod, shar print_libav_error(LOG_LEVEL_ERROR, MOD_NAME "Cannot make frame writable", ret); return {}; } - s->in_frame->pts = frame_seq++; + s->in_frame->pts += 1; if (s->decoder != vc_memcpy) { int src_linesize = vc_get_linesize(tx->tiles[0].width, tx->color_spec);