gstvideoencoder: make sure the buffer is writable before modifying metadata
authorJordan Petridis <jordan@centricular.com>
Tue, 20 Apr 2021 08:06:09 +0000 (11:06 +0300)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Tue, 20 Apr 2021 16:01:15 +0000 (16:01 +0000)
Similar to ae8d0cf3acfaf79d8479647a55bd44b8453d07df

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/1112>

gst-libs/gst/video/gstvideoencoder.c

index b9dfc46..0d85ba2 100644 (file)
@@ -2563,6 +2563,9 @@ gst_video_encoder_finish_frame (GstVideoEncoder * encoder,
   frame->distance_from_sync = priv->distance_from_sync;
   priv->distance_from_sync++;
 
+  /* We need a writable buffer for the metadata changes below */
+  frame->output_buffer = gst_buffer_make_writable (frame->output_buffer);
+
   GST_BUFFER_PTS (frame->output_buffer) = frame->pts;
   GST_BUFFER_DTS (frame->output_buffer) = frame->dts;
   GST_BUFFER_DURATION (frame->output_buffer) = frame->duration;
@@ -2709,6 +2712,9 @@ gst_video_encoder_finish_subframe (GstVideoEncoder * encoder,
 
   gst_video_encoder_infer_dts_unlocked (encoder, frame);
 
+  /* We need a writable buffer for the metadata changes below */
+  subframe_buffer = gst_buffer_make_writable (subframe_buffer);
+
   GST_BUFFER_PTS (subframe_buffer) = frame->pts;
   GST_BUFFER_DTS (subframe_buffer) = frame->dts;
   GST_BUFFER_DURATION (subframe_buffer) = frame->duration;