diff options
author | Jan Schmidt <jan@centricular.com> | 2021-08-30 23:26:39 +1000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2021-09-06 16:49:21 +0100 |
commit | 520f516a4bc5e9750cd3ceeb153a095b43085b5b (patch) | |
tree | 4b6c9d68170683f8d87abcd4f636cc35c862e99b /ext/mpeg2enc/gstmpeg2encpicturereader.cc | |
parent | 90606b9f701468b184aebb070965159f0400853c (diff) | |
download | gstreamer-plugins-bad-520f516a4bc5e9750cd3ceeb153a095b43085b5b.tar.gz |
mpeg2enc: Only allow 1 pending frame for encoding
Having an unlimited input queue is very bad if the
encoder can't run at real-time. Eventually it will
consume all RAM. I don't really see any reason to
have more than 1 outstanding encoded frame, so
remove the queue and limit things to 1 pending frame.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2510>
Diffstat (limited to 'ext/mpeg2enc/gstmpeg2encpicturereader.cc')
-rw-r--r-- | ext/mpeg2enc/gstmpeg2encpicturereader.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ext/mpeg2enc/gstmpeg2encpicturereader.cc b/ext/mpeg2enc/gstmpeg2encpicturereader.cc index 3641b613a..b0c5484d9 100644 --- a/ext/mpeg2enc/gstmpeg2encpicturereader.cc +++ b/ext/mpeg2enc/gstmpeg2encpicturereader.cc @@ -135,7 +135,7 @@ bool GST_MPEG2ENC_MUTEX_LOCK (enc); /* hang around until the element provides us with a buffer */ - while (!(inframe = (GstVideoCodecFrame *)g_queue_pop_head (enc->frames))) { + while (enc->pending_frame == NULL) { if (enc->eos) { GST_MPEG2ENC_MUTEX_UNLOCK (enc); /* inform the mpeg encoding loop that it can give up */ @@ -144,7 +144,9 @@ bool GST_MPEG2ENC_WAIT (enc); } + inframe = enc->pending_frame; gst_video_frame_map (&vframe, &enc->input_state->info, inframe->input_buffer, GST_MAP_READ); + enc->pending_frame = NULL; frame = GST_VIDEO_FRAME_COMP_DATA (&vframe, 0); s = GST_VIDEO_FRAME_COMP_STRIDE (&vframe, 0); |