From 9e7454a90abe7ea6075e3bcaa0731ed4a8a22b54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 2 Jul 2015 18:51:09 +0200 Subject: [PATCH] openh264dec: Unref video frames and codec state in all cases --- ext/openh264/gstopenh264dec.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ext/openh264/gstopenh264dec.cpp b/ext/openh264/gstopenh264dec.cpp index 3e37d01ac6..6333fe4979 100644 --- a/ext/openh264/gstopenh264dec.cpp +++ b/ext/openh264/gstopenh264dec.cpp @@ -271,6 +271,7 @@ gst_openh264dec_handle_frame (GstVideoDecoder * decoder, if (frame) { if (!gst_buffer_map (frame->input_buffer, &map_info, GST_MAP_READ)) { GST_ERROR_OBJECT (openh264dec, "Cannot map input buffer!"); + gst_video_codec_frame_unref (frame); return GST_FLOW_ERROR; } @@ -305,8 +306,10 @@ gst_openh264dec_handle_frame (GstVideoDecoder * decoder, ret = openh264dec->priv->decoder->DecodeFrame2 (NULL, 0, yuvdata, &dst_buf_info); - if (ret != dsErrorFree) + if (ret != dsErrorFree) { + gst_video_codec_frame_unref (frame); return GST_FLOW_EOS; + } } /* FIXME: openh264 has no way for us to get a connection @@ -321,6 +324,7 @@ gst_openh264dec_handle_frame (GstVideoDecoder * decoder, /* No output available yet */ if (dst_buf_info.iBufferStatus != 1) { + gst_video_codec_frame_unref (frame); return (frame ? GST_FLOW_OK : GST_FLOW_EOS); } @@ -339,6 +343,8 @@ gst_openh264dec_handle_frame (GstVideoDecoder * decoder, if (!gst_video_decoder_negotiate (decoder)) { GST_ERROR_OBJECT (openh264dec, "Failed to negotiate with downstream elements"); + gst_video_codec_state_unref (state); + gst_video_codec_frame_unref (frame); return GST_FLOW_NOT_NEGOTIATED; } } else { @@ -348,6 +354,7 @@ gst_openh264dec_handle_frame (GstVideoDecoder * decoder, flow_status = gst_video_decoder_allocate_output_frame (decoder, frame); if (flow_status != GST_FLOW_OK) { gst_video_codec_state_unref (state); + gst_video_codec_frame_unref (frame); return flow_status; } @@ -355,6 +362,7 @@ gst_openh264dec_handle_frame (GstVideoDecoder * decoder, GST_MAP_WRITE)) { GST_ERROR_OBJECT (openh264dec, "Cannot map output buffer!"); gst_video_codec_state_unref (state); + gst_video_codec_frame_unref (frame); return GST_FLOW_ERROR; }