rtpvp8pay: allocate bitreader on the stack

This commit is contained in:
Tim-Philipp Müller 2014-06-18 13:44:31 +01:00
parent 725b8f272b
commit 4b1f771e4d

View file

@ -174,10 +174,10 @@ static gboolean
gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer,
gsize buffer_size)
{
GstBitReader *reader = NULL;
GstMapInfo map = GST_MAP_INFO_INIT;
GstBitReader reader;
guint8 *data;
gsize size;
GstMapInfo map;
int i;
gboolean keyframe;
guint32 partition0_size;
@ -196,7 +196,8 @@ gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer,
data = map.data;
size = map.size;
reader = gst_bit_reader_new (data, size);
gst_bit_reader_init (&reader, data, size);
self->is_keyframe = keyframe = ((data[0] & 0x1) == 0);
version = (data[0] >> 1) & 0x7;
@ -213,22 +214,22 @@ gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer,
offset = keyframe ? 10 : 3;
partition0_size += offset;
if (!gst_bit_reader_skip (reader, 24))
if (!gst_bit_reader_skip (&reader, 24))
goto error;
if (keyframe) {
/* check start tag: 0x9d 0x01 0x2a */
if (!gst_bit_reader_get_bits_uint8 (reader, &tmp8, 8) || tmp8 != 0x9d)
if (!gst_bit_reader_get_bits_uint8 (&reader, &tmp8, 8) || tmp8 != 0x9d)
goto error;
if (!gst_bit_reader_get_bits_uint8 (reader, &tmp8, 8) || tmp8 != 0x01)
if (!gst_bit_reader_get_bits_uint8 (&reader, &tmp8, 8) || tmp8 != 0x01)
goto error;
if (!gst_bit_reader_get_bits_uint8 (reader, &tmp8, 8) || tmp8 != 0x2a)
if (!gst_bit_reader_get_bits_uint8 (&reader, &tmp8, 8) || tmp8 != 0x2a)
goto error;
/* Skip horizontal size code (16 bits) vertical size code (16 bits) */
if (!gst_bit_reader_skip (reader, 32))
if (!gst_bit_reader_skip (&reader, 32))
goto error;
}
@ -333,14 +334,12 @@ gst_rtp_vp8_pay_parse_frame (GstRtpVP8Pay * self, GstBuffer * buffer,
self->partition_offset[i + 1] = size;
gst_bit_reader_free (reader);
gst_buffer_unmap (buffer, &map);
return TRUE;
error:
GST_DEBUG ("Failed to parse frame");
if (reader) {
gst_bit_reader_free (reader);
if (map.memory != NULL) {
gst_buffer_unmap (buffer, &map);
}
return FALSE;