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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8153>
This commit is contained in:
Dean Zhang (张安迪) 2025-01-06 20:30:51 +08:00 committed by Nicolas Dufresne
parent 06a0ab7b33
commit e000a1ec1f

View file

@ -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;