asfdemux: use new bytereader functions for image tag parsing

This commit is contained in:
Tim-Philipp Müller 2009-06-23 01:37:01 +01:00
parent 1874bf5910
commit aa0d6f7b48
2 changed files with 16 additions and 28 deletions

View file

@ -47,7 +47,7 @@ AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL
dnl *** required versions of GStreamer stuff ***
GST_REQ=0.10.23
GST_REQ=0.10.23.1
GSTPB_REQ=0.10.23
dnl *** autotools stuff ****

View file

@ -33,6 +33,7 @@
#endif
#include <gst/gstutils.h>
#include <gst/base/gstbytereader.h>
#include <gst/riff/riff-media.h>
#include <gst/tag/tag.h>
#include <gst/gst-i18n-plugin.h>
@ -2141,38 +2142,25 @@ static void
asf_demux_parse_picture_tag (GstTagList * tags, const guint8 * tag_data,
guint tag_data_len)
{
const guint8 *data = tag_data;
guint pic_type, img_data_len;
guint len = tag_data_len;
GstByteReader r;
const guint8 *img_data;
guint32 img_data_len;
guint8 pic_type;
if (len < (1 + 4 + 2 + 2 + 1))
gst_byte_reader_init (&r, tag_data, tag_data_len);
/* skip mime type string (we don't trust it and do our own typefinding),
* and also skip the description string, since we don't use it */
if (!gst_byte_reader_get_uint8 (&r, &pic_type) ||
!gst_byte_reader_get_uint32_le (&r, &img_data_len) ||
!gst_byte_reader_skip_string_utf16 (&r) ||
!gst_byte_reader_skip_string_utf16 (&r) ||
!gst_byte_reader_get_data (&r, img_data_len, &img_data)) {
goto not_enough_data;
pic_type = GST_READ_UINT8 (data);
data += 1, len -= 1;
img_data_len = GST_READ_UINT32_LE (data);
data += 4, len -= 4;
/* skip mime type string (we don't trust it and do our own typefinding) */
while (len >= 2 && GST_READ_UINT16_LE (data) != 0) {
data += 2, len -= 2;
}
if (len < 2)
goto not_enough_data;
data += 2, len -= 2;
/* skip description string */
while (len >= 2 && GST_READ_UINT16_LE (data) != 0) {
data += 2, len -= 2;
}
if (len < 2)
goto not_enough_data;
data += 2, len -= 2;
if (len < img_data_len)
goto not_enough_data;
if (!gst_tag_list_add_id3_image (tags, data, img_data_len, pic_type))
if (!gst_tag_list_add_id3_image (tags, img_data, img_data_len, pic_type))
GST_DEBUG ("failed to add image extracted from WM/Picture tag to taglist");
return;