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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2014>
This commit is contained in:
He Junyan 2021-02-11 16:04:12 +08:00
parent e8df47b022
commit 636a77a83f

View file

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