mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-01 21:18:52 +00:00
celtenc: cleanup header creation
Avoid an extra copy via a temporary fixed size stack buffer. Use libcelt's header size to allocate a buffer of the correct size in the first place (libcelt has an off by 4 there, so account for this). While there, make size unsigned, and granpos signed. https://bugzilla.gnome.org/show_bug.cgi?id=659087
This commit is contained in:
parent
06764fcd3f
commit
d8684fffa1
1 changed files with 11 additions and 7 deletions
|
@ -699,16 +699,18 @@ encoder_creation_failed:
|
||||||
/* prepare a buffer for transmission */
|
/* prepare a buffer for transmission */
|
||||||
static GstBuffer *
|
static GstBuffer *
|
||||||
gst_celt_enc_buffer_from_data (GstCeltEnc * enc, guchar * data,
|
gst_celt_enc_buffer_from_data (GstCeltEnc * enc, guchar * data,
|
||||||
gint data_len, guint64 granulepos)
|
guint data_len, gint64 granulepos)
|
||||||
{
|
{
|
||||||
GstBuffer *outbuf;
|
GstBuffer *outbuf;
|
||||||
|
|
||||||
outbuf = gst_buffer_new_and_alloc (data_len);
|
outbuf = gst_buffer_new ();
|
||||||
memcpy (GST_BUFFER_DATA (outbuf), data, data_len);
|
GST_BUFFER_DATA (outbuf) = data;
|
||||||
|
GST_BUFFER_MALLOCDATA (outbuf) = data;
|
||||||
|
GST_BUFFER_SIZE (outbuf) = data_len;
|
||||||
GST_BUFFER_OFFSET (outbuf) = enc->bytes_out;
|
GST_BUFFER_OFFSET (outbuf) = enc->bytes_out;
|
||||||
GST_BUFFER_OFFSET_END (outbuf) = granulepos;
|
GST_BUFFER_OFFSET_END (outbuf) = granulepos;
|
||||||
|
|
||||||
GST_LOG_OBJECT (enc, "encoded buffer of %d bytes", GST_BUFFER_SIZE (outbuf));
|
GST_LOG_OBJECT (enc, "encoded buffer of %u bytes", GST_BUFFER_SIZE (outbuf));
|
||||||
return outbuf;
|
return outbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -907,11 +909,13 @@ gst_celt_enc_chain (GstPad * pad, GstBuffer * buf)
|
||||||
constraints */
|
constraints */
|
||||||
GstBuffer *buf1, *buf2;
|
GstBuffer *buf1, *buf2;
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
guchar data[100];
|
/* libcelt has a bug which underestimates header size by 4... */
|
||||||
|
unsigned int header_size = enc->header.header_size + 4;
|
||||||
|
unsigned char *data = g_malloc (header_size);
|
||||||
|
|
||||||
/* create header buffer */
|
/* create header buffer */
|
||||||
celt_header_to_packet (&enc->header, data, 100);
|
celt_header_to_packet (&enc->header, data, header_size);
|
||||||
buf1 = gst_celt_enc_buffer_from_data (enc, data, 100, 0);
|
buf1 = gst_celt_enc_buffer_from_data (enc, data, header_size, 0);
|
||||||
|
|
||||||
/* create comment buffer */
|
/* create comment buffer */
|
||||||
buf2 = gst_celt_enc_create_metadata_buffer (enc);
|
buf2 = gst_celt_enc_create_metadata_buffer (enc);
|
||||||
|
|
Loading…
Reference in a new issue