summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungha Yang <seungha@centricular.com>2021-05-15 00:39:57 +0900
committerTim-Philipp Müller <tim@centricular.com>2021-05-20 16:30:09 +0100
commitf1d80b87ee122068f4019926654277d9763e16d2 (patch)
treef863dfa407fca1ae8e770a439897d8735802b996
parente9201ea6ad577dd65b7d993b1347bf062c788c6d (diff)
downloadgstreamer-plugins-bad-f1d80b87ee122068f4019926654277d9763e16d2.tar.gz
interlace: Fix too small buffer size error
Even though input/output resolutions are identical there, default buffer size of progressive and interleaved formats could be different because we are rounding up height of all plane of interlaced frame to be multiple of two. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2270>
-rw-r--r--gst/interlace/gstinterlace.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/gst/interlace/gstinterlace.c b/gst/interlace/gstinterlace.c
index 896cab9e7..6f4d2f922 100644
--- a/gst/interlace/gstinterlace.c
+++ b/gst/interlace/gstinterlace.c
@@ -1030,15 +1030,16 @@ static void
copy_fields (GstInterlace * interlace, GstBuffer * dest, GstBuffer * src,
int field_index)
{
- GstVideoInfo *info = &interlace->info;
+ GstVideoInfo *in_info = &interlace->info;
+ GstVideoInfo *out_info = &interlace->out_info;
gint i, j, n_planes;
guint8 *d, *s;
GstVideoFrame dframe, sframe;
- if (!gst_video_frame_map (&dframe, info, dest, GST_MAP_WRITE))
+ if (!gst_video_frame_map (&dframe, out_info, dest, GST_MAP_WRITE))
goto dest_map_failed;
- if (!gst_video_frame_map (&sframe, info, src, GST_MAP_READ))
+ if (!gst_video_frame_map (&sframe, in_info, src, GST_MAP_READ))
goto src_map_failed;
n_planes = GST_VIDEO_FRAME_N_PLANES (&dframe);
@@ -1253,6 +1254,8 @@ gst_interlace_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
GstBuffer *output_buffer, *output_buffer2 = NULL;
guint n_output_fields;
gboolean interlaced = FALSE;
+ GstVideoInfo *in_info = &interlace->info;
+ GstVideoInfo *out_info = &interlace->out_info;
GST_DEBUG ("have %d fields, %d current, %d stored",
num_fields, current_fields, interlace->stored_fields);
@@ -1272,7 +1275,8 @@ gst_interlace_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
if (!output_buffer2)
return GST_FLOW_ERROR;
} else {
- output_buffer = gst_buffer_new_and_alloc (gst_buffer_get_size (buffer));
+ output_buffer =
+ gst_buffer_new_and_alloc (GST_VIDEO_INFO_SIZE (out_info));
/* take the first field from the stored frame */
copy_fields (interlace, output_buffer, interlace->stored_frame,
interlace->field_index);
@@ -1295,7 +1299,32 @@ gst_interlace_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
if (!output_buffer2)
return GST_FLOW_ERROR;
} else {
- output_buffer = gst_buffer_copy (buffer);
+ GstVideoFrame dframe, sframe;
+
+ output_buffer =
+ gst_buffer_new_and_alloc (GST_VIDEO_INFO_SIZE (out_info));
+
+ if (!gst_video_frame_map (&dframe,
+ out_info, output_buffer, GST_MAP_WRITE)) {
+ GST_ELEMENT_ERROR (interlace, CORE, FAILED,
+ ("Failed to write map buffer"), ("Failed to map output buffer"));
+ gst_buffer_unref (output_buffer);
+ gst_buffer_unref (buffer);
+ return GST_FLOW_ERROR;
+ }
+
+ if (!gst_video_frame_map (&sframe, in_info, buffer, GST_MAP_READ)) {
+ GST_ELEMENT_ERROR (interlace, CORE, FAILED,
+ ("Failed to read map buffer"), ("Failed to map input buffer"));
+ gst_video_frame_unmap (&dframe);
+ gst_buffer_unref (output_buffer);
+ gst_buffer_unref (buffer);
+ return GST_FLOW_ERROR;
+ }
+
+ gst_video_frame_copy (&dframe, &sframe);
+ gst_video_frame_unmap (&dframe);
+ gst_video_frame_unmap (&sframe);
}
if (num_fields >= 3 && interlace->allow_rff) {