mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
rawbaseparse: Fix output buffer size trimming
For frame->buffer, baseparse is doing that automatically for us. For frame->output_buffer it doesn't and assumes that the subclass is already doing that. Consistency!
This commit is contained in:
parent
0c79a06dd1
commit
a4f1d4a265
1 changed files with 18 additions and 10 deletions
|
@ -432,7 +432,7 @@ done:
|
|||
|
||||
static GstBuffer *
|
||||
gst_raw_base_parse_align_buffer (GstRawBaseParse * raw_base_parse,
|
||||
gsize alignment, GstBuffer * buffer)
|
||||
gsize alignment, GstBuffer * buffer, gsize out_size)
|
||||
{
|
||||
GstMapInfo map;
|
||||
|
||||
|
@ -440,32 +440,32 @@ gst_raw_base_parse_align_buffer (GstRawBaseParse * raw_base_parse,
|
|||
|
||||
if (map.size < sizeof (guintptr)) {
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return buffer;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (((guintptr) map.data) & (alignment - 1)) {
|
||||
GstBuffer *new_buffer;
|
||||
GstAllocationParams params = { 0, alignment - 1, 0, 0, };
|
||||
|
||||
new_buffer = gst_buffer_new_allocate (NULL,
|
||||
gst_buffer_get_size (buffer), ¶ms);
|
||||
new_buffer = gst_buffer_new_allocate (NULL, out_size, ¶ms);
|
||||
|
||||
/* Copy data "by hand", so ensure alignment is kept: */
|
||||
gst_buffer_fill (new_buffer, 0, map.data, map.size);
|
||||
gst_buffer_fill (new_buffer, 0, map.data, out_size);
|
||||
|
||||
gst_buffer_copy_into (new_buffer, buffer, GST_BUFFER_COPY_METADATA, 0, -1);
|
||||
gst_buffer_copy_into (new_buffer, buffer, GST_BUFFER_COPY_METADATA, 0,
|
||||
out_size);
|
||||
GST_DEBUG_OBJECT (raw_base_parse,
|
||||
"We want output aligned on %" G_GSIZE_FORMAT ", reallocated",
|
||||
alignment);
|
||||
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
gst_buffer_unref (buffer);
|
||||
|
||||
return new_buffer;
|
||||
}
|
||||
|
||||
gst_buffer_unmap (buffer, &map);
|
||||
return buffer;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
|
@ -609,9 +609,17 @@ gst_raw_base_parse_handle_frame (GstBaseParse * parse,
|
|||
&& (alignment =
|
||||
klass->get_alignment (raw_base_parse,
|
||||
GST_RAW_BASE_PARSE_CONFIG_CURRENT)) != 1) {
|
||||
frame->out_buffer =
|
||||
GstBuffer *aligned_buffer;
|
||||
|
||||
aligned_buffer =
|
||||
gst_raw_base_parse_align_buffer (raw_base_parse, alignment,
|
||||
gst_buffer_ref (frame->buffer));
|
||||
frame->out_buffer ? frame->out_buffer : frame->buffer, out_size);
|
||||
|
||||
if (aligned_buffer) {
|
||||
if (frame->out_buffer)
|
||||
gst_buffer_unref (frame->out_buffer);
|
||||
frame->out_buffer = aligned_buffer;
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the duration of the output buffer, or if none exists, of
|
||||
|
|
Loading…
Reference in a new issue