videodecoder: Make sure the buffer is writable before changing fields in finish_frame() too

We can't be sure that we have the one and only reference here either.
This commit is contained in:
Sebastian Dröge 2012-07-05 13:38:48 +02:00
parent 8e15a2c28d
commit 7803ae97e9

View file

@ -2189,21 +2189,6 @@ gst_video_decoder_finish_frame (GstVideoDecoder * decoder,
goto done; goto done;
} }
GST_BUFFER_FLAG_UNSET (frame->output_buffer, GST_BUFFER_FLAG_DELTA_UNIT);
/* set PTS and DTS to both the PTS for decoded frames */
GST_BUFFER_PTS (frame->output_buffer) = frame->pts;
GST_BUFFER_DTS (frame->output_buffer) = frame->pts;
GST_BUFFER_DURATION (frame->output_buffer) = frame->duration;
GST_BUFFER_OFFSET (frame->output_buffer) = GST_BUFFER_OFFSET_NONE;
GST_BUFFER_OFFSET_END (frame->output_buffer) = GST_BUFFER_OFFSET_NONE;
if (priv->discont) {
GST_BUFFER_FLAG_SET (frame->output_buffer, GST_BUFFER_FLAG_DISCONT);
priv->discont = FALSE;
}
/* A reference always needs to be owned by the frame on the buffer. /* A reference always needs to be owned by the frame on the buffer.
* For that reason, we use a complete sub-buffer (zero-cost) to push * For that reason, we use a complete sub-buffer (zero-cost) to push
* downstream. * downstream.
@ -2211,6 +2196,21 @@ gst_video_decoder_finish_frame (GstVideoDecoder * decoder,
* current implementation are done with the frame. */ * current implementation are done with the frame. */
output_buffer = gst_buffer_copy (frame->output_buffer); output_buffer = gst_buffer_copy (frame->output_buffer);
GST_BUFFER_FLAG_UNSET (output_buffer, GST_BUFFER_FLAG_DELTA_UNIT);
/* set PTS and DTS to both the PTS for decoded frames */
GST_BUFFER_PTS (output_buffer) = frame->pts;
GST_BUFFER_DTS (output_buffer) = frame->pts;
GST_BUFFER_DURATION (output_buffer) = frame->duration;
GST_BUFFER_OFFSET (output_buffer) = GST_BUFFER_OFFSET_NONE;
GST_BUFFER_OFFSET_END (output_buffer) = GST_BUFFER_OFFSET_NONE;
if (priv->discont) {
GST_BUFFER_FLAG_SET (output_buffer, GST_BUFFER_FLAG_DISCONT);
priv->discont = FALSE;
}
if (decoder->output_segment.rate < 0.0) { if (decoder->output_segment.rate < 0.0) {
GST_LOG_OBJECT (decoder, "queued frame"); GST_LOG_OBJECT (decoder, "queued frame");
priv->output_queued = g_list_prepend (priv->output_queued, output_buffer); priv->output_queued = g_list_prepend (priv->output_queued, output_buffer);