Commit 20669d46 authored by Thibault Saunier's avatar Thibault Saunier

Fix 'ignoring return value of function declared with const attribute'

This always happens with GstByteReader/Writer and friends when
not taking into account returned boolean of the _read/_write functions
(which is actually wrong).

Make use of the *_unchecked variant as much as possible, or take the
returned value into account.
parent a7eda9ed
......@@ -1309,7 +1309,8 @@ gst_h264_parser_identify_nalu_avc (GstH264NalParser * nalparser,
size = size - offset;
gst_bit_reader_init (&br, data + offset, size);
gst_bit_reader_get_bits_uint32 (&br, &nalu->size, nal_length_size * 8);
nalu->size = gst_bit_reader_get_bits_uint32_unchecked (&br,
nal_length_size * 8);
nalu->sc_offset = offset;
nalu->offset = offset + nal_length_size;
......
......@@ -277,7 +277,7 @@ find_psc (GstByteReader * br)
psc_pos = gst_byte_reader_get_pos (br);
break;
} else
gst_byte_reader_skip (br, 1);
gst_byte_reader_skip_unchecked (br, 1);
}
failed:
......@@ -543,7 +543,7 @@ gst_h263_parse (GstMpeg4Packet * packet,
packet->offset = off1 + offset;
packet->data = data;
gst_byte_reader_skip (&br, 3);
gst_byte_reader_skip_unchecked (&br, 3);
off2 = find_psc (&br);
if (off2 == -1) {
......
......@@ -97,9 +97,8 @@ find_start_code (GstBitReader * b)
while (gst_bit_reader_peek_bits_uint32 (b, &bits, 32)) {
if (bits >> 8 == 0x1) {
return TRUE;
} else {
gst_bit_reader_skip (b, 8);
}
} else if (!gst_bit_reader_skip (b, 8) == FALSE)
break;
}
return FALSE;
......@@ -324,10 +323,13 @@ gst_mpeg_video_parse (const guint8 * data, gsize size, guint offset)
while (off >= 0 && off + 3 < size) {
GstMpegVideoTypeOffsetSize *codoffsize;
gst_byte_reader_skip (&br, off + 3);
if (gst_byte_reader_skip (&br, off + 3) == FALSE)
goto failed;
codoffsize = g_malloc (sizeof (GstMpegVideoTypeOffsetSize));
gst_byte_reader_get_uint8 (&br, &codoffsize->type);
if (gst_byte_reader_get_uint8 (&br, &codoffsize->type) == FALSE)
goto failed;
codoffsize->offset = gst_byte_reader_get_pos (&br) + offset;
......@@ -346,6 +348,12 @@ gst_mpeg_video_parse (const guint8 * data, gsize size, guint offset)
}
return g_list_reverse (ret);
failed:
{
GST_WARNING ("Failed to parse");
return g_list_reverse (ret);
}
}
/**
......
......@@ -692,7 +692,7 @@ get_unary (GstBitReader * br, gint stop, gint len)
guint8 current = 0xff;
for (i = 0; i < len; i++) {
gst_bit_reader_get_bits_uint8 (br, &current, 1);
current = gst_bit_reader_get_bits_uint8_unchecked (br, 1);
if (current == stop)
return i;
}
......
......@@ -163,11 +163,14 @@ gst_aiff_mux_write_form_header (GstAiffMux * aiffmux, guint32 audio_data_size,
GstByteWriter * writer)
{
/* ckID == 'FORM' */
gst_byte_writer_put_uint32_le (writer, GST_MAKE_FOURCC ('F', 'O', 'R', 'M'));
gst_byte_writer_put_uint32_le_unchecked (writer,
GST_MAKE_FOURCC ('F', 'O', 'R', 'M'));
/* ckSize is currently bogus but we'll know what it is later */
gst_byte_writer_put_uint32_be (writer, audio_data_size + AIFF_HEADER_LEN - 8);
gst_byte_writer_put_uint32_be_unchecked (writer,
audio_data_size + AIFF_HEADER_LEN - 8);
/* formType == 'AIFF' */
gst_byte_writer_put_uint32_le (writer, GST_MAKE_FOURCC ('A', 'I', 'F', 'F'));
gst_byte_writer_put_uint32_le_unchecked (writer,
GST_MAKE_FOURCC ('A', 'I', 'F', 'F'));
}
/*
......@@ -218,8 +221,8 @@ gst_aiff_mux_write_ext (GstByteWriter * writer, double d)
if (d < 0)
ext.exponent[0] |= 0x80;
gst_byte_writer_put_data (writer, ext.exponent, 2);
gst_byte_writer_put_data (writer, ext.mantissa, 8);
gst_byte_writer_put_data_unchecked (writer, ext.exponent, 2);
gst_byte_writer_put_data_unchecked (writer, ext.mantissa, 8);
}
/*
......@@ -230,13 +233,14 @@ static void
gst_aiff_mux_write_comm_header (GstAiffMux * aiffmux, guint32 audio_data_size,
GstByteWriter * writer)
{
gst_byte_writer_put_uint32_le (writer, GST_MAKE_FOURCC ('C', 'O', 'M', 'M'));
gst_byte_writer_put_uint32_be (writer, 18);
gst_byte_writer_put_uint16_be (writer, aiffmux->channels);
gst_byte_writer_put_uint32_le_unchecked (writer,
GST_MAKE_FOURCC ('C', 'O', 'M', 'M'));
gst_byte_writer_put_uint32_be_unchecked (writer, 18);
gst_byte_writer_put_uint16_be_unchecked (writer, aiffmux->channels);
/* numSampleFrames value will be overwritten when known */
gst_byte_writer_put_uint32_be (writer,
gst_byte_writer_put_uint32_be_unchecked (writer,
audio_data_size / (aiffmux->width / 8 * aiffmux->channels));
gst_byte_writer_put_uint16_be (writer, aiffmux->depth);
gst_byte_writer_put_uint16_be_unchecked (writer, aiffmux->depth);
gst_aiff_mux_write_ext (writer, aiffmux->rate);
}
......@@ -244,13 +248,14 @@ static void
gst_aiff_mux_write_ssnd_header (GstAiffMux * aiffmux, guint32 audio_data_size,
GstByteWriter * writer)
{
gst_byte_writer_put_uint32_le (writer, GST_MAKE_FOURCC ('S', 'S', 'N', 'D'));
gst_byte_writer_put_uint32_le_unchecked (writer,
GST_MAKE_FOURCC ('S', 'S', 'N', 'D'));
/* ckSize will be overwritten when known */
gst_byte_writer_put_uint32_be (writer,
gst_byte_writer_put_uint32_be_unchecked (writer,
audio_data_size + AIFF_SSND_HEADER_LEN - 8);
/* offset and blockSize are set to 0 as we don't support block-aligned sample data yet */
gst_byte_writer_put_uint32_be (writer, 0);
gst_byte_writer_put_uint32_be (writer, 0);
gst_byte_writer_put_uint32_be_unchecked (writer, 0);
gst_byte_writer_put_uint32_be_unchecked (writer, 0);
}
static GstFlowReturn
......
......@@ -895,10 +895,8 @@ gst_h264_parse_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_static_pad_template (gstelement_class,
&srctemplate);
gst_element_class_add_static_pad_template (gstelement_class,
&sinktemplate);
gst_element_class_add_static_pad_template (gstelement_class, &srctemplate);
gst_element_class_add_static_pad_template (gstelement_class, &sinktemplate);
gst_element_class_set_details_simple (gstelement_class, "H264Parse",
"Codec/Parser/Video",
"Parses raw h264 stream",
......@@ -1732,7 +1730,7 @@ gst_h264_parse_push_buffer (GstH264Parse * h264parse, GstBuffer * buf)
GstBuffer *codec_nal, *new_buf;
gst_byte_writer_init_with_size (&bw, GST_BUFFER_SIZE (buf), FALSE);
gst_byte_writer_put_data (&bw, GST_BUFFER_DATA (buf),
gst_byte_writer_put_data_unchecked (&bw, GST_BUFFER_DATA (buf),
h264parse->idr_offset);
GST_DEBUG_OBJECT (h264parse, "- inserting SPS/PPS");
for (i = 0; i < MAX_SPS_COUNT; i++) {
......@@ -1741,8 +1739,8 @@ gst_h264_parse_push_buffer (GstH264Parse * h264parse, GstBuffer * buf)
codec_nal = gst_buffer_copy (h264parse->sps_nals[i]);
codec_nal =
gst_h264_parse_write_nal_prefix (h264parse, codec_nal);
gst_byte_writer_put_data (&bw, GST_BUFFER_DATA (codec_nal),
GST_BUFFER_SIZE (codec_nal));
gst_byte_writer_put_data_unchecked (&bw,
GST_BUFFER_DATA (codec_nal), GST_BUFFER_SIZE (codec_nal));
h264parse->last_report = timestamp;
}
}
......@@ -1752,12 +1750,12 @@ gst_h264_parse_push_buffer (GstH264Parse * h264parse, GstBuffer * buf)
codec_nal = gst_buffer_copy (h264parse->pps_nals[i]);
codec_nal =
gst_h264_parse_write_nal_prefix (h264parse, codec_nal);
gst_byte_writer_put_data (&bw, GST_BUFFER_DATA (codec_nal),
GST_BUFFER_SIZE (codec_nal));
gst_byte_writer_put_data_unchecked (&bw,
GST_BUFFER_DATA (codec_nal), GST_BUFFER_SIZE (codec_nal));
h264parse->last_report = timestamp;
}
}
gst_byte_writer_put_data (&bw,
gst_byte_writer_put_data_unchecked (&bw,
GST_BUFFER_DATA (buf) + h264parse->idr_offset,
GST_BUFFER_SIZE (buf) - h264parse->idr_offset);
/* collect result and push */
......
......@@ -828,7 +828,11 @@ write_plt (GstJP2kDecimator * self, GstByteWriter * writer,
plt_end_pos = gst_byte_writer_get_pos (writer);
gst_byte_writer_set_pos (writer, plt_start_pos);
gst_byte_writer_put_uint16_be (writer, plt_end_pos - plt_start_pos);
if (!gst_byte_writer_put_uint16_be (writer, plt_end_pos - plt_start_pos)) {
GST_ERROR_OBJECT (self, "Not enough space to write plt size");
return GST_FLOW_ERROR;
}
gst_byte_writer_set_pos (writer, plt_end_pos);
return GST_FLOW_OK;
......@@ -1328,9 +1332,9 @@ write_packet (GstJP2kDecimator * self, GstByteWriter * writer,
}
if (packet->sop) {
gst_byte_writer_put_uint16_be (writer, MARKER_SOP);
gst_byte_writer_put_uint16_be (writer, 4);
gst_byte_writer_put_uint16_be (writer, packet->seqno);
gst_byte_writer_put_uint16_be_unchecked (writer, MARKER_SOP);
gst_byte_writer_put_uint16_be_unchecked (writer, 4);
gst_byte_writer_put_uint16_be_unchecked (writer, packet->seqno);
}
if (packet->data) {
......@@ -1696,7 +1700,7 @@ write_main_header (GstJP2kDecimator * self, GstByteWriter * writer,
return GST_FLOW_ERROR;
}
gst_byte_writer_put_uint16_be (writer, MARKER_SOC);
gst_byte_writer_put_uint16_be_unchecked (writer, MARKER_SOC);
ret = write_siz (self, writer, &header->siz);
if (ret != GST_FLOW_OK)
......
......@@ -441,7 +441,7 @@ mxf_mpeg_is_mpeg2_keyframe (GstBuffer * buffer)
guint8 type = 0;
/* Found sync code */
gst_byte_reader_skip (&reader, 3);
gst_byte_reader_skip_unchecked (&reader, 3);
if (!gst_byte_reader_get_uint8 (&reader, &type))
break;
......@@ -465,9 +465,8 @@ mxf_mpeg_is_mpeg2_keyframe (GstBuffer * buffer)
return FALSE;
}
}
} else {
gst_byte_reader_skip (&reader, 1);
}
} else if (gst_byte_reader_skip (&reader, 1) == FALSE)
break;
}
return FALSE;
......@@ -484,7 +483,7 @@ mxf_mpeg_is_mpeg4_keyframe (GstBuffer * buffer)
guint8 type = 0;
/* Found sync code */
gst_byte_reader_skip (&reader, 3);
gst_byte_reader_skip_unchecked (&reader, 3);
if (!gst_byte_reader_get_uint8 (&reader, &type))
break;
......@@ -502,9 +501,8 @@ mxf_mpeg_is_mpeg4_keyframe (GstBuffer * buffer)
return FALSE;
}
}
} else {
gst_byte_reader_skip (&reader, 1);
}
} else if (gst_byte_reader_skip (&reader, 1) == FALSE)
break;
}
return FALSE;
......@@ -1024,7 +1022,7 @@ mxf_mpeg_is_mpeg2_frame (GstBuffer * buffer)
guint8 type = 0;
/* Found sync code */
gst_byte_reader_skip (&reader, 3);
gst_byte_reader_skip_unchecked (&reader, 3);
if (!gst_byte_reader_get_uint8 (&reader, &type))
break;
......@@ -1034,7 +1032,8 @@ mxf_mpeg_is_mpeg2_frame (GstBuffer * buffer)
return TRUE;
}
} else {
gst_byte_reader_skip (&reader, 1);
if (gst_byte_reader_skip (&reader, 1) == FALSE)
break;
}
}
......@@ -1052,7 +1051,7 @@ mxf_mpeg_is_mpeg4_frame (GstBuffer * buffer)
guint8 type = 0;
/* Found sync code */
gst_byte_reader_skip (&reader, 3);
gst_byte_reader_skip_unchecked (&reader, 3);
if (!gst_byte_reader_get_uint8 (&reader, &type))
break;
......@@ -1062,7 +1061,8 @@ mxf_mpeg_is_mpeg4_frame (GstBuffer * buffer)
return TRUE;
}
} else {
gst_byte_reader_skip (&reader, 1);
if (gst_byte_reader_skip (&reader, 1) == FALSE)
break;
}
}
......
......@@ -65,10 +65,8 @@ gst_h263_parse_base_init (gpointer g_class)
{
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_static_pad_template (gstelement_class,
&srctemplate);
gst_element_class_add_static_pad_template (gstelement_class,
&sinktemplate);
gst_element_class_add_static_pad_template (gstelement_class, &srctemplate);
gst_element_class_add_static_pad_template (gstelement_class, &sinktemplate);
gst_element_class_set_details_simple (gstelement_class, "H.263 parser",
"Codec/Parser/Video",
"Parses H.263 streams",
......@@ -163,7 +161,8 @@ find_psc (GstBuffer * buffer, guint skip)
if (!gst_byte_reader_set_pos (&br, skip))
goto out;
gst_byte_reader_peek_uint24_be (&br, &psc);
if (gst_byte_reader_peek_uint24_be (&br, &psc) == FALSE)
goto out;
/* Scan for the picture start code (22 bits - 0x0020) */
while ((gst_byte_reader_get_remaining (&br) >= 3)) {
......@@ -171,8 +170,8 @@ find_psc (GstBuffer * buffer, guint skip)
((psc & 0xffffc0) == 0x000080)) {
psc_pos = gst_byte_reader_get_pos (&br);
break;
} else
gst_byte_reader_skip (&br, 1);
} else if (gst_byte_reader_skip (&br, 1) == FALSE)
break;
}
out:
......
......@@ -1491,30 +1491,30 @@ gst_h264_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
const gboolean bs = h264parse->format == GST_H264_PARSE_FORMAT_BYTE;
gst_byte_writer_init_with_size (&bw, GST_BUFFER_SIZE (buffer), FALSE);
gst_byte_writer_put_data (&bw, GST_BUFFER_DATA (buffer),
gst_byte_writer_put_data_unchecked (&bw, GST_BUFFER_DATA (buffer),
h264parse->idr_pos);
GST_DEBUG_OBJECT (h264parse, "- inserting SPS/PPS");
for (i = 0; i < GST_H264_MAX_SPS_COUNT; i++) {
if ((codec_nal = h264parse->sps_nals[i])) {
GST_DEBUG_OBJECT (h264parse, "inserting SPS nal");
gst_byte_writer_put_uint32_be (&bw,
gst_byte_writer_put_uint32_be_unchecked (&bw,
bs ? 1 : GST_BUFFER_SIZE (codec_nal));
gst_byte_writer_put_data (&bw, GST_BUFFER_DATA (codec_nal),
GST_BUFFER_SIZE (codec_nal));
gst_byte_writer_put_data_unchecked (&bw,
GST_BUFFER_DATA (codec_nal), GST_BUFFER_SIZE (codec_nal));
h264parse->last_report = new_ts;
}
}
for (i = 0; i < GST_H264_MAX_PPS_COUNT; i++) {
if ((codec_nal = h264parse->pps_nals[i])) {
GST_DEBUG_OBJECT (h264parse, "inserting PPS nal");
gst_byte_writer_put_uint32_be (&bw,
gst_byte_writer_put_uint32_be_unchecked (&bw,
bs ? 1 : GST_BUFFER_SIZE (codec_nal));
gst_byte_writer_put_data (&bw, GST_BUFFER_DATA (codec_nal),
GST_BUFFER_SIZE (codec_nal));
gst_byte_writer_put_data_unchecked (&bw,
GST_BUFFER_DATA (codec_nal), GST_BUFFER_SIZE (codec_nal));
h264parse->last_report = new_ts;
}
}
gst_byte_writer_put_data (&bw,
gst_byte_writer_put_data_unchecked (&bw,
GST_BUFFER_DATA (buffer) + h264parse->idr_pos,
GST_BUFFER_SIZE (buffer) - h264parse->idr_pos);
/* collect result and push */
......
......@@ -687,23 +687,25 @@ gst_vdp_h264_dec_parse_data (GstBaseVideoDecoder * base_video_decoder,
gst_bit_reader_init_from_buffer (&reader, buf);
if (gst_bit_reader_get_remaining (&reader) <
h264_dec->nal_length_size * 8 + 7)
goto invalid_packet;
/* skip nal_length or sync code */
gst_bit_reader_skip (&reader, h264_dec->nal_length_size * 8);
gst_bit_reader_skip_unchecked (&reader, h264_dec->nal_length_size * 8);
forbidden_zero_bit = gst_bit_reader_get_bits_uint8_unchecked (&reader, 1);
if (!gst_bit_reader_get_bits_uint8 (&reader, &forbidden_zero_bit, 1))
goto invalid_packet;
if (forbidden_zero_bit != 0) {
GST_WARNING ("forbidden_zero_bit != 0");
return GST_FLOW_ERROR;
}
if (!gst_bit_reader_get_bits_uint16 (&reader, &nal_unit.ref_idc, 2))
goto invalid_packet;
nal_unit.ref_idc = gst_bit_reader_get_bits_uint16_unchecked (&reader, 2);
GST_DEBUG ("nal_ref_idc: %u", nal_unit.ref_idc);
/* read nal_unit_type */
if (!gst_bit_reader_get_bits_uint16 (&reader, &nal_unit.type, 5))
goto invalid_packet;
nal_unit.type = gst_bit_reader_get_bits_uint16_unchecked (&reader, 5);
GST_DEBUG ("nal_unit_type: %u", nal_unit.type);
if (nal_unit.type == 14 || nal_unit.type == 20) {
......@@ -716,7 +718,7 @@ gst_vdp_h264_dec_parse_data (GstBaseVideoDecoder * base_video_decoder,
size = gst_bit_reader_get_remaining (&reader) / 8;
i = size - 1;
while (size > 0 && data[i] == 0x00) {
while ((gint) size > 0 && data[i] == 0x00) {
size--;
i--;
}
......
......@@ -415,12 +415,14 @@ gst_vdp_mpeg_dec_parse_data (GstBaseVideoDecoder * base_video_decoder,
GstBitReader b_reader = GST_BIT_READER_INIT_FROM_BUFFER (buf);
guint8 start_code;
if (gst_bit_reader_get_remaining (&b_reader) < 8 * 3 + 8)
return GST_FLOW_ERROR;
/* skip sync_code */
gst_bit_reader_skip (&b_reader, 8 * 3);
gst_bit_reader_skip_unchecked (&b_reader, 8 * 3);
/* start_code */
if (!gst_bit_reader_get_bits_uint8 (&b_reader, &start_code, 8))
return GST_FLOW_ERROR;
start_code = gst_bit_reader_get_bits_uint8_unchecked (&b_reader, 8);
mpeg_frame = GST_VDP_MPEG_FRAME_CAST (frame);
......@@ -624,8 +626,7 @@ gst_vdp_mpeg_dec_base_init (gpointer gclass)
"Decode mpeg stream with vdpau",
"Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com>");
gst_element_class_add_static_pad_template (element_class,
&sink_template);
gst_element_class_add_static_pad_template (element_class, &sink_template);
}
/* initialize the vdpaumpegdecoder's class */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment