gboolean ret = TRUE;
g_return_val_if_fail (GST_IS_VIDEO_DECODER (decoder), FALSE);
+ g_return_val_if_fail (decoder->priv->output_state, FALSE);
klass = GST_VIDEO_DECODER_GET_CLASS (decoder);
gst_video_decoder_allocate_output_buffer (GstVideoDecoder * decoder)
{
GstFlowReturn flow;
- GstBuffer *buffer;
+ GstBuffer *buffer = NULL;
+
+ g_return_val_if_fail (decoder->priv->output_state, NULL);
GST_DEBUG ("alloc src buffer");
GST_VIDEO_DECODER_STREAM_LOCK (decoder);
if (G_UNLIKELY (decoder->priv->output_state_changed
- || (decoder->priv->output_state
- && gst_pad_check_reconfigure (decoder->srcpad))))
- gst_video_decoder_negotiate (decoder);
+ || gst_pad_check_reconfigure (decoder->srcpad))) {
+ if (!gst_video_decoder_negotiate (decoder)) {
+ GST_DEBUG_OBJECT (decoder, "Failed to negotiate, fallback allocation");
+ goto fallback;
+ }
+ }
flow = gst_buffer_pool_acquire_buffer (decoder->priv->pool, &buffer, NULL);
- GST_VIDEO_DECODER_STREAM_UNLOCK (decoder);
-
if (flow != GST_FLOW_OK) {
GST_INFO_OBJECT (decoder, "couldn't allocate output buffer, flow %s",
gst_flow_get_name (flow));
- buffer = NULL;
+ goto fallback;
}
+ GST_VIDEO_DECODER_STREAM_UNLOCK (decoder);
+
+ return buffer;
+
+fallback:
+ buffer =
+ gst_buffer_new_allocate (NULL, decoder->priv->output_state->info.size,
+ NULL);
+
+ GST_VIDEO_DECODER_STREAM_UNLOCK (decoder);
return buffer;
}
GstVideoCodecState *state;
int num_bytes;
+ g_return_val_if_fail (decoder->priv->output_state, GST_FLOW_NOT_NEGOTIATED);
g_return_val_if_fail (frame->output_buffer == NULL, GST_FLOW_ERROR);
GST_VIDEO_DECODER_STREAM_LOCK (decoder);
}
if (G_UNLIKELY (decoder->priv->output_state_changed
- || (decoder->priv->output_state
- && gst_pad_check_reconfigure (decoder->srcpad))))
+ || gst_pad_check_reconfigure (decoder->srcpad)))
gst_video_decoder_negotiate (decoder);
GST_LOG_OBJECT (decoder, "alloc buffer size %d", num_bytes);
gboolean ret = TRUE;
g_return_val_if_fail (GST_IS_VIDEO_ENCODER (encoder), FALSE);
+ g_return_val_if_fail (encoder->priv->output_state, FALSE);
klass = GST_VIDEO_ENCODER_GET_CLASS (encoder);
{
GstBuffer *buffer;
+ g_return_val_if_fail (encoder->priv->output_state, NULL);
g_return_val_if_fail (size > 0, NULL);
GST_DEBUG ("alloc src buffer");
GST_VIDEO_ENCODER_STREAM_LOCK (encoder);
if (G_UNLIKELY (encoder->priv->output_state_changed
- || (encoder->priv->output_state
- && gst_pad_check_reconfigure (encoder->srcpad))))
- gst_video_encoder_negotiate (encoder);
+ || gst_pad_check_reconfigure (encoder->srcpad))) {
+ if (!gst_video_encoder_negotiate (encoder)) {
+ GST_DEBUG_OBJECT (encoder, "Failed to negotiate, fallback allocation");
+ goto fallback;
+ }
+ }
buffer =
gst_buffer_new_allocate (encoder->priv->allocator, size,
&encoder->priv->params);
+ if (!buffer) {
+ GST_INFO_OBJECT (encoder, "couldn't allocate output buffer");
+ goto fallback;
+ }
+
+ GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder);
+
+ return buffer;
+
+fallback:
+ buffer = gst_buffer_new_allocate (NULL, size, NULL);
GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder);
encoder, GstVideoCodecFrame * frame, gsize size)
{
g_return_val_if_fail (frame->output_buffer == NULL, GST_FLOW_ERROR);
+ g_return_val_if_fail (encoder->priv->output_state, GST_FLOW_NOT_NEGOTIATED);
GST_VIDEO_ENCODER_STREAM_LOCK (encoder);
if (G_UNLIKELY (encoder->priv->output_state_changed
- || (encoder->priv->output_state
- && gst_pad_check_reconfigure (encoder->srcpad))))
+ || gst_pad_check_reconfigure (encoder->srcpad)))
gst_video_encoder_negotiate (encoder);
GST_LOG_OBJECT (encoder, "alloc buffer size %" G_GSIZE_FORMAT, size);