From e000a1ec1ffa41e3b49dfc3b332b94dbef34e9f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dean=20Zhang=20=28=E5=BC=A0=E5=AE=89=E8=BF=AA=29?= Date: Mon, 6 Jan 2025 20:30:51 +0800 Subject: [PATCH] v4l2videodec: release decode only frame in input list For some frames with decode-only flag, the v4l2 decoder will not put them in output list. The corresponding decode-only frames will be still kept in input list, which may cause potential performance issue when the input list is full. So release the decode-only frames according to the decode-only flag after they are processed by decoder driver. Part-of: --- .../gst-plugins-good/sys/v4l2/gstv4l2videodec.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2videodec.c b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2videodec.c index dc91c90dbf..32e188478f 100644 --- a/subprojects/gst-plugins-good/sys/v4l2/gstv4l2videodec.c +++ b/subprojects/gst-plugins-good/sys/v4l2/gstv4l2videodec.c @@ -837,9 +837,17 @@ gst_v4l2_video_dec_loop (GstVideoDecoder * decoder) gboolean warned = FALSE; /* Garbage collect old frames in case of codec bugs */ - while ((oldest_frame = gst_video_decoder_get_oldest_frame (decoder)) && - check_system_frame_number_too_old (frame->system_frame_number, - oldest_frame->system_frame_number)) { + while ((oldest_frame = gst_video_decoder_get_oldest_frame (decoder))) { + if (frame->system_frame_number > oldest_frame->system_frame_number && + GST_VIDEO_CODEC_FRAME_IS_DECODE_ONLY (oldest_frame)) { + gst_video_decoder_finish_frame (decoder, oldest_frame); + oldest_frame = NULL; + continue; + } + + if (G_LIKELY (!check_system_frame_number_too_old + (frame->system_frame_number, oldest_frame->system_frame_number))) + break; if (oldest_frame->system_frame_number > 0) { gst_video_decoder_drop_frame (decoder, oldest_frame); oldest_frame = NULL;