isomp4: Check return value of GstByteWriter

And use unchecked variant of GstByteReader where applicable
This commit is contained in:
Edward Hervey 2012-04-12 15:48:57 +02:00
parent eb0cdfe20f
commit 97591c1e77
3 changed files with 39 additions and 35 deletions

View file

@ -4215,36 +4215,38 @@ build_jp2h_extension (AtomTRAK * trak, gint width, gint height,
idhr_size + colr_size + cmap_size + cdef_size, TRUE); idhr_size + colr_size + cmap_size + cdef_size, TRUE);
/* ihdr = image header box */ /* ihdr = image header box */
gst_byte_writer_put_uint32_be (&writer, 22); gst_byte_writer_put_uint32_be_unchecked (&writer, 22);
gst_byte_writer_put_uint32_le (&writer, GST_MAKE_FOURCC ('i', 'h', 'd', 'r')); gst_byte_writer_put_uint32_le_unchecked (&writer, GST_MAKE_FOURCC ('i', 'h',
gst_byte_writer_put_uint32_be (&writer, height); 'd', 'r'));
gst_byte_writer_put_uint32_be (&writer, width); gst_byte_writer_put_uint32_be_unchecked (&writer, height);
gst_byte_writer_put_uint16_be (&writer, ncomp); gst_byte_writer_put_uint32_be_unchecked (&writer, width);
gst_byte_writer_put_uint16_be_unchecked (&writer, ncomp);
/* 8 bits per component, unsigned */ /* 8 bits per component, unsigned */
gst_byte_writer_put_uint8 (&writer, 0x7); gst_byte_writer_put_uint8_unchecked (&writer, 0x7);
/* compression type; reserved */ /* compression type; reserved */
gst_byte_writer_put_uint8 (&writer, 0x7); gst_byte_writer_put_uint8_unchecked (&writer, 0x7);
/* colour space (un)known */ /* colour space (un)known */
gst_byte_writer_put_uint8 (&writer, 0x0); gst_byte_writer_put_uint8_unchecked (&writer, 0x0);
/* intellectual property right (box present) */ /* intellectual property right (box present) */
gst_byte_writer_put_uint8 (&writer, 0x0); gst_byte_writer_put_uint8_unchecked (&writer, 0x0);
/* colour specification box */ /* colour specification box */
gst_byte_writer_put_uint32_be (&writer, 15); gst_byte_writer_put_uint32_be_unchecked (&writer, 15);
gst_byte_writer_put_uint32_le (&writer, GST_MAKE_FOURCC ('c', 'o', 'l', 'r')); gst_byte_writer_put_uint32_le_unchecked (&writer, GST_MAKE_FOURCC ('c', 'o',
'l', 'r'));
/* specification method: enumerated */ /* specification method: enumerated */
gst_byte_writer_put_uint8 (&writer, 0x1); gst_byte_writer_put_uint8_unchecked (&writer, 0x1);
/* precedence; reserved */ /* precedence; reserved */
gst_byte_writer_put_uint8 (&writer, 0x0); gst_byte_writer_put_uint8_unchecked (&writer, 0x0);
/* approximation; reserved */ /* approximation; reserved */
gst_byte_writer_put_uint8 (&writer, 0x0); gst_byte_writer_put_uint8_unchecked (&writer, 0x0);
/* enumerated colourspace */ /* enumerated colourspace */
gst_byte_writer_put_uint32_be (&writer, cenum); gst_byte_writer_put_uint32_be_unchecked (&writer, cenum);
if (cmap_array) { if (cmap_array) {
gst_byte_writer_put_uint32_be (&writer, cmap_size); gst_byte_writer_put_uint32_be_unchecked (&writer, cmap_size);
gst_byte_writer_put_uint32_le (&writer, gst_byte_writer_put_uint32_le_unchecked (&writer,
GST_MAKE_FOURCC ('c', 'm', 'a', 'p')); GST_MAKE_FOURCC ('c', 'm', 'a', 'p'));
for (i = 0; i < cmap_array_size; i++) { for (i = 0; i < cmap_array_size; i++) {
const GValue *item; const GValue *item;
@ -4264,33 +4266,33 @@ build_jp2h_extension (AtomTRAK * trak, gint width, gint height,
GST_WARNING ("MTYP of cmap atom signals Pallete Mapping, but we don't " GST_WARNING ("MTYP of cmap atom signals Pallete Mapping, but we don't "
"handle Pallete mapping atoms yet"); "handle Pallete mapping atoms yet");
gst_byte_writer_put_uint16_be (&writer, cmp); gst_byte_writer_put_uint16_be_unchecked (&writer, cmp);
gst_byte_writer_put_uint8 (&writer, mtyp); gst_byte_writer_put_uint8_unchecked (&writer, mtyp);
gst_byte_writer_put_uint8 (&writer, pcol); gst_byte_writer_put_uint8_unchecked (&writer, pcol);
} }
} }
if (cdef_array) { if (cdef_array) {
gst_byte_writer_put_uint32_be (&writer, cdef_size); gst_byte_writer_put_uint32_be_unchecked (&writer, cdef_size);
gst_byte_writer_put_uint32_le (&writer, gst_byte_writer_put_uint32_le_unchecked (&writer,
GST_MAKE_FOURCC ('c', 'd', 'e', 'f')); GST_MAKE_FOURCC ('c', 'd', 'e', 'f'));
gst_byte_writer_put_uint16_be (&writer, cdef_array_size); gst_byte_writer_put_uint16_be_unchecked (&writer, cdef_array_size);
for (i = 0; i < cdef_array_size; i++) { for (i = 0; i < cdef_array_size; i++) {
const GValue *item; const GValue *item;
gint value; gint value;
item = gst_value_array_get_value (cdef_array, i); item = gst_value_array_get_value (cdef_array, i);
value = g_value_get_int (item); value = g_value_get_int (item);
gst_byte_writer_put_uint16_be (&writer, i); gst_byte_writer_put_uint16_be_unchecked (&writer, i);
if (value > 0) { if (value > 0) {
gst_byte_writer_put_uint16_be (&writer, 0); gst_byte_writer_put_uint16_be_unchecked (&writer, 0);
gst_byte_writer_put_uint16_be (&writer, value); gst_byte_writer_put_uint16_be_unchecked (&writer, value);
} else if (value < 0) { } else if (value < 0) {
gst_byte_writer_put_uint16_be (&writer, -value); gst_byte_writer_put_uint16_be_unchecked (&writer, -value);
gst_byte_writer_put_uint16_be (&writer, 0); /* TODO what here? */ gst_byte_writer_put_uint16_be_unchecked (&writer, 0); /* TODO what here? */
} else { } else {
gst_byte_writer_put_uint16_be (&writer, 1); gst_byte_writer_put_uint16_be_unchecked (&writer, 1);
gst_byte_writer_put_uint16_be (&writer, 0); gst_byte_writer_put_uint16_be_unchecked (&writer, 0);
} }
} }
} }

View file

@ -6251,7 +6251,8 @@ qtdemux_get_rtsp_uri_from_hndl (GstQTDemux * qtdemux, GNode * minf)
break; break;
} }
/* skipping to the next entry */ /* skipping to the next entry */
gst_byte_reader_skip (&dref, atom_size - 8); if (!gst_byte_reader_skip (&dref, atom_size - 8))
break;
} else { } else {
GST_WARNING_OBJECT (qtdemux, "Failed to parse hndl child " GST_WARNING_OBJECT (qtdemux, "Failed to parse hndl child "
"atom header"); "atom header");
@ -6261,7 +6262,8 @@ qtdemux_get_rtsp_uri_from_hndl (GstQTDemux * qtdemux, GNode * minf)
break; break;
} }
/* skip to the next entry */ /* skip to the next entry */
gst_byte_reader_skip (&dref, size - 8); if (!gst_byte_reader_skip (&dref, size - 8))
break;
} else { } else {
GST_WARNING_OBJECT (qtdemux, "Error parsing dref atom"); GST_WARNING_OBJECT (qtdemux, "Error parsing dref atom");
} }

View file

@ -64,7 +64,7 @@ qtdemux_dump_mvhd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
GST_LOG ("%*s pref. rate: %g", depth, "", GET_FP32 (data)); GST_LOG ("%*s pref. rate: %g", depth, "", GET_FP32 (data));
GST_LOG ("%*s pref. volume: %g", depth, "", GET_FP16 (data)); GST_LOG ("%*s pref. volume: %g", depth, "", GET_FP16 (data));
gst_byte_reader_skip (data, 46); gst_byte_reader_skip_unchecked (data, 46);
GST_LOG ("%*s preview time: %u", depth, "", GET_UINT32 (data)); GST_LOG ("%*s preview time: %u", depth, "", GET_UINT32 (data));
GST_LOG ("%*s preview dur.: %u", depth, "", GET_UINT32 (data)); GST_LOG ("%*s preview dur.: %u", depth, "", GET_UINT32 (data));
GST_LOG ("%*s poster time: %u", depth, "", GET_UINT32 (data)); GST_LOG ("%*s poster time: %u", depth, "", GET_UINT32 (data));
@ -281,7 +281,7 @@ qtdemux_dump_stsd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
return FALSE; return FALSE;
qt_atom_parser_peek_sub (data, 0, 78, &sub); qt_atom_parser_peek_sub (data, 0, 78, &sub);
gst_byte_reader_skip (&sub, 6); gst_byte_reader_skip_unchecked (&sub, 6);
GST_LOG ("%*s data reference:%d", depth, "", GET_UINT16 (&sub)); GST_LOG ("%*s data reference:%d", depth, "", GET_UINT16 (&sub));
GST_LOG ("%*s version/rev.: %08x", depth, "", GET_UINT32 (&sub)); GST_LOG ("%*s version/rev.: %08x", depth, "", GET_UINT32 (&sub));
fourcc = GET_FOURCC (&sub); fourcc = GET_FOURCC (&sub);
@ -297,7 +297,7 @@ qtdemux_dump_stsd (GstQTDemux * qtdemux, GstByteReader * data, int depth)
GST_LOG ("%*s frame count: %u", depth, "", GET_UINT16 (&sub)); GST_LOG ("%*s frame count: %u", depth, "", GET_UINT16 (&sub));
/* something is not right with this, it's supposed to be a string but it's /* something is not right with this, it's supposed to be a string but it's
* not apparently, so just skip this for now */ * not apparently, so just skip this for now */
gst_byte_reader_skip (&sub, 1 + 31); gst_byte_reader_skip_unchecked (&sub, 1 + 31);
GST_LOG ("%*s compressor: (skipped)", depth, ""); GST_LOG ("%*s compressor: (skipped)", depth, "");
GST_LOG ("%*s depth: %u", depth, "", GET_UINT16 (&sub)); GST_LOG ("%*s depth: %u", depth, "", GET_UINT16 (&sub));
GST_LOG ("%*s color table ID:%u", depth, "", GET_UINT16 (&sub)); GST_LOG ("%*s color table ID:%u", depth, "", GET_UINT16 (&sub));