summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2012-07-23 10:40:14 +0200
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2012-07-23 10:40:14 +0200
commit899fd3d76e3353d2ed7dc5aea1d8dbbc9c0aeb10 (patch)
treedb36b21043a100052f82bf5a4bce249289f18e61
parent941f4c331b7b3fcd71442b1e3bf9bb4c741579ac (diff)
ffvidenc: Allocate output buffers with the base class functions
-rw-r--r--ext/ffmpeg/gstffmpegvidenc.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/ext/ffmpeg/gstffmpegvidenc.c b/ext/ffmpeg/gstffmpegvidenc.c
index e636eda..4204e08 100644
--- a/ext/ffmpeg/gstffmpegvidenc.c
+++ b/ext/ffmpeg/gstffmpegvidenc.c
@@ -716,7 +716,13 @@ gst_ffmpegvidenc_handle_frame (GstVideoEncoder * encoder,
frame = gst_video_encoder_get_oldest_frame (encoder);
/* Allocate output buffer */
- frame->output_buffer = outbuf = gst_buffer_new_and_alloc (ret_size);
+ if (gst_video_encoder_allocate_output_frame (encoder, frame,
+ ret_size) != GST_FLOW_OK) {
+ gst_video_codec_frame_unref (frame);
+ goto alloc_fail;
+ }
+
+ outbuf = frame->output_buffer;
gst_buffer_fill (outbuf, 0, ffmpegenc->working_buf, ret_size);
/* buggy codec may not set coded_frame */
@@ -743,6 +749,16 @@ encode_fail:
#endif /* GST_DISABLE_GST_DEBUG */
return GST_FLOW_OK;
}
+alloc_fail:
+ {
+#ifndef GST_DISABLE_GST_DEBUG
+ GstFFMpegVidEncClass *oclass =
+ (GstFFMpegVidEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc));
+ GST_ERROR_OBJECT (ffmpegenc,
+ "avenc_%s: failed to allocate buffer", oclass->in_plugin->name);
+#endif /* GST_DISABLE_GST_DEBUG */
+ return GST_FLOW_ERROR;
+ }
}
static void
@@ -773,6 +789,7 @@ gst_ffmpegvidenc_flush_buffers (GstFFMpegVidEnc * ffmpegenc, gboolean send)
GST_WARNING_OBJECT (ffmpegenc,
"avenc_%s: failed to flush buffer", oclass->in_plugin->name);
#endif /* GST_DISABLE_GST_DEBUG */
+ gst_video_codec_frame_unref (frame);
break;
}
@@ -783,7 +800,18 @@ gst_ffmpegvidenc_flush_buffers (GstFFMpegVidEnc * ffmpegenc, gboolean send)
(("Could not write to file \"%s\"."), ffmpegenc->filename),
GST_ERROR_SYSTEM);
- frame->output_buffer = outbuf = gst_buffer_new_and_alloc (ret_size);
+ if (gst_video_encoder_allocate_output_frame (GST_VIDEO_ENCODER (ffmpegenc),
+ frame, ret_size) != GST_FLOW_OK) {
+#ifndef GST_DISABLE_GST_DEBUG
+ GstFFMpegVidEncClass *oclass =
+ (GstFFMpegVidEncClass *) (G_OBJECT_GET_CLASS (ffmpegenc));
+ GST_WARNING_OBJECT (ffmpegenc,
+ "avenc_%s: failed to allocate buffer", oclass->in_plugin->name);
+#endif /* GST_DISABLE_GST_DEBUG */
+ gst_video_codec_frame_unref (frame);
+ break;
+ }
+ outbuf = frame->output_buffer;
gst_buffer_fill (outbuf, 0, ffmpegenc->working_buf, ret_size);
if (ffmpegenc->context->coded_frame->key_frame)