From 636a77a83f6462c9bdd85101ff19cd0a82e5a2ba Mon Sep 17 00:00:00 2001 From: He Junyan Date: Thu, 11 Feb 2021 16:04:12 +0800 Subject: [PATCH] codecs: mpeg2decoder: Move frame_unref to handle_frame. In the current code, we call frame_unref only when the frame is outputted. This is OK for normal playback, but when seek happens, the frames stored in DPB is not outputted and causes some memory leak. The correct way is that we should call frame_unref every time we finish the handle_frame(), which is also the behaviour of H264/H265 decoder. Part-of: --- gst-libs/gst/codecs/gstmpeg2decoder.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gst-libs/gst/codecs/gstmpeg2decoder.c b/gst-libs/gst/codecs/gstmpeg2decoder.c index 18b11ed870..d9c275349b 100644 --- a/gst-libs/gst/codecs/gstmpeg2decoder.c +++ b/gst-libs/gst/codecs/gstmpeg2decoder.c @@ -1053,8 +1053,6 @@ gst_mpeg2_decoder_do_output_picture (GstMpeg2Decoder * decoder, GST_TIME_ARGS (frame->pts)); ret = klass->output_picture (decoder, frame, to_output); - gst_video_codec_frame_unref (frame); - return ret; } @@ -1159,6 +1157,7 @@ gst_mpeg2_decoder_handle_frame (GstVideoDecoder * decoder, ret = gst_mpeg2_decoder_output_current_picture (self); gst_mpeg2_picture_clear (&priv->current_picture); gst_mpeg2_picture_clear (&priv->first_field); + gst_video_codec_frame_unref (priv->current_frame); priv->current_frame = NULL; return ret;