[Pkg-gstreamer-commits] [gstreamer-vaapi] 16/176: vaapiencode: fix error handling while allocating output buffers.
Vincent Cheng
vcheng at moszumanska.debian.org
Tue Jun 3 08:09:23 UTC 2014
This is an automated email from the git hooks/post-receive script.
vcheng pushed a commit to branch upstream
in repository gstreamer-vaapi.
commit 207264abc49430ea1747458a6f09a5acea393d45
Author: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
Date: Tue Nov 26 17:26:44 2013 +0100
vaapiencode: fix error handling while allocating output buffers.
Fix default GstVideoEncoder::allocate_buffer() implementation to properly
unmap the coded buffer prior to returning an error.
---
gst/vaapi/gstvaapiencode.c | 43 ++++++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 15 deletions(-)
diff --git a/gst/vaapi/gstvaapiencode.c b/gst/vaapi/gstvaapiencode.c
index 060f0e7..215be01 100644
--- a/gst/vaapi/gstvaapiencode.c
+++ b/gst/vaapi/gstvaapiencode.c
@@ -129,6 +129,7 @@ static GstFlowReturn
gst_vaapiencode_default_allocate_buffer (GstVaapiEncode * encode,
GstVaapiCodedBuffer * coded_buf, GstBuffer ** outbuf_ptr)
{
+ GstVideoEncoder *const venc = GST_VIDEO_ENCODER_CAST (encode);
GstBuffer *buf;
gint32 buf_size;
@@ -139,27 +140,39 @@ gst_vaapiencode_default_allocate_buffer (GstVaapiEncode * encode,
return GST_VAAPI_ENCODE_FLOW_MEM_ERROR;
buf_size = gst_vaapi_coded_buffer_get_size (coded_buf);
- if (buf_size <= 0) {
- GST_ERROR ("get GstVaapiCodedBuf buffer size:%d", buf_size);
+ if (buf_size <= 0)
+ goto error_invalid_buffer;
+
+ buf = gst_video_encoder_allocate_output_buffer (venc, buf_size);
+ if (!buf)
+ goto error_create_buffer;
+ if (!gst_vaapi_coded_buffer_get_buffer (coded_buf, buf))
+ goto error_copy_buffer;
+
+ gst_vaapi_coded_buffer_unmap (coded_buf);
+ *outbuf_ptr = buf;
+ return GST_FLOW_OK;
+
+ /* ERRORS */
+error_invalid_buffer:
+ {
+ GST_ERROR ("invalid GstVaapiCodedBuffer size (%d)", buf_size);
+ gst_vaapi_coded_buffer_unmap (coded_buf);
return GST_VAAPI_ENCODE_FLOW_MEM_ERROR;
}
-
- buf =
- gst_video_encoder_allocate_output_buffer (GST_VIDEO_ENCODER_CAST (encode),
- buf_size);
- if (!buf) {
- GST_ERROR ("failed to allocate output buffer of size %d", buf_size);
+error_create_buffer:
+ {
+ GST_ERROR ("failed to create output buffer of size %d", buf_size);
+ gst_vaapi_coded_buffer_unmap (coded_buf);
return GST_VAAPI_ENCODE_FLOW_MEM_ERROR;
}
-
- if (!gst_vaapi_coded_buffer_get_buffer (coded_buf, buf)) {
- GST_ERROR ("failed to get encoded buffer");
- gst_buffer_replace (&buf, NULL);
+error_copy_buffer:
+ {
+ GST_ERROR ("failed to copy GstVaapiCodedBuffer data");
+ gst_buffer_unref (buf);
+ gst_vaapi_coded_buffer_unmap (coded_buf);
return GST_VAAPI_ENCODE_FLOW_MEM_ERROR;
}
- gst_vaapi_coded_buffer_unmap (coded_buf);
- *outbuf_ptr = buf;
- return GST_FLOW_OK;
}
static GstFlowReturn
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gstreamer/gstreamer-vaapi.git
More information about the Pkg-gstreamer-commits
mailing list