mfvideoenc: Fix huge memory leak

Subclass must unref passed GstVideoCodecFrame on GstVideoEncoder::handle_frame()

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1294>
This commit is contained in:
Seungha Yang 2020-05-24 19:12:28 +09:00
parent 5a2c358a2b
commit b93fbdd3cd

View file

@ -296,7 +296,6 @@ gst_mf_video_enc_process_input (GstMFVideoEnc * self,
if (!gst_video_frame_map (&vframe, info, frame->input_buffer, GST_MAP_READ)) { if (!gst_video_frame_map (&vframe, info, frame->input_buffer, GST_MAP_READ)) {
GST_ERROR_OBJECT (self, "Couldn't map input frame"); GST_ERROR_OBJECT (self, "Couldn't map input frame");
gst_video_codec_frame_unref (frame);
return FALSE; return FALSE;
} }
@ -522,11 +521,12 @@ gst_mf_video_enc_handle_frame (GstVideoEncoder * enc,
GstVideoCodecFrame * frame) GstVideoCodecFrame * frame)
{ {
GstMFVideoEnc *self = GST_MF_VIDEO_ENC (enc); GstMFVideoEnc *self = GST_MF_VIDEO_ENC (enc);
GstFlowReturn ret; GstFlowReturn ret = GST_FLOW_OK;
if (!gst_mf_video_enc_process_input (self, frame)) { if (!gst_mf_video_enc_process_input (self, frame)) {
GST_ERROR_OBJECT (self, "Failed to process input"); GST_ERROR_OBJECT (self, "Failed to process input");
return GST_FLOW_ERROR; ret = GST_FLOW_ERROR;
goto done;
} }
do { do {
@ -536,6 +536,9 @@ gst_mf_video_enc_handle_frame (GstVideoEncoder * enc,
if (ret == GST_MF_TRANSFORM_FLOW_NEED_DATA) if (ret == GST_MF_TRANSFORM_FLOW_NEED_DATA)
ret = GST_FLOW_OK; ret = GST_FLOW_OK;
done:
gst_video_codec_frame_unref (frame);
return ret; return ret;
} }