summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2010-04-20 15:37:03 +0200
committerMark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>2010-04-20 15:39:07 +0200
commit00148e3736ba61a5b5707511091b0d57ef026098 (patch)
tree0c34cc2874ae3d24c46f9a3fc82b7a1c922f7a2b /gst
parentc4aaab2d590a10a7cfe826742406c85c00d858c6 (diff)
downloadgstreamer-plugins-bad-00148e3736ba61a5b5707511091b0d57ef026098.tar.gz
mpeg4videoparse: also set short configuration data in codec_data
That is, header configuration may start at Video Object (startcode), rather than at Visual Object Sequence, which is catered for and parsed, so let's also take it as codec_data if no more available. Fixes (remainder of) #572551.
Diffstat (limited to 'gst')
-rw-r--r--gst/mpeg4videoparse/mpeg4videoparse.c34
1 files changed, 25 insertions, 9 deletions
diff --git a/gst/mpeg4videoparse/mpeg4videoparse.c b/gst/mpeg4videoparse/mpeg4videoparse.c
index bfcf84516..1e3b4960c 100644
--- a/gst/mpeg4videoparse/mpeg4videoparse.c
+++ b/gst/mpeg4videoparse/mpeg4videoparse.c
@@ -210,10 +210,26 @@ static gint aspect_ratio_table[6][2] = { {-1, -1}, {1, 1}, {12, 11},
{10, 11}, {16, 11}, {40, 33}
};
+static void
+gst_mpeg4vparse_set_config (GstMpeg4VParse * parse, const guint8 * data,
+ gsize size)
+{
+ /* limit possible caps noise */
+ if (parse->config && size == GST_BUFFER_SIZE (parse->config) &&
+ memcmp (GST_BUFFER_DATA (parse->config), data, size) == 0)
+ return;
+
+ if (parse->config != NULL)
+ gst_buffer_unref (parse->config);
+
+ parse->config = gst_buffer_new_and_alloc (size);
+ memcpy (GST_BUFFER_DATA (parse->config), data, size);
+}
+
/* Handle parsing a video object */
static gboolean
gst_mpeg4vparse_handle_vo (GstMpeg4VParse * parse, const guint8 * data,
- gsize size)
+ gsize size, gboolean set_codec_data)
{
guint32 bits;
bitstream_t bs = { data, 0, 0, size };
@@ -222,6 +238,9 @@ gst_mpeg4vparse_handle_vo (GstMpeg4VParse * parse, const guint8 * data,
gint aspect_ratio_width = -1, aspect_ratio_height = -1;
gint height = -1, width = -1;
+ if (set_codec_data)
+ gst_mpeg4vparse_set_config (parse, data, size);
+
/* expecting a video object startcode */
GET_BITS (&bs, 32, &bits);
if (bits > 0x11F)
@@ -384,11 +403,7 @@ gst_mpeg4vparse_handle_vos (GstMpeg4VParse * parse, const guint8 * data,
/* Even if we fail to parse, then some other element might succeed, so always
* put the VOS in the config */
parse->profile = profile;
- if (parse->config != NULL)
- gst_buffer_unref (parse->config);
-
- parse->config = gst_buffer_new_and_alloc (size);
- memcpy (GST_BUFFER_DATA (parse->config), data, size);
+ gst_mpeg4vparse_set_config (parse, data, size);
parse->have_config = TRUE;
@@ -440,7 +455,7 @@ gst_mpeg4vparse_handle_vos (GstMpeg4VParse * parse, const guint8 * data,
data = &bs.data[bs.offset];
size -= bs.offset;
- return gst_mpeg4vparse_handle_vo (parse, data, size);
+ return gst_mpeg4vparse_handle_vo (parse, data, size, FALSE);
out:
return gst_mpeg4vparse_set_new_caps (parse, 0, 0, -1, -1, -1, -1);
@@ -577,7 +592,7 @@ gst_mpeg4vparse_drain (GstMpeg4VParse * parse, GstBuffer * last_buffer)
/* end of VOS found, interpret the config data and restart the
* search for the VOP */
gst_mpeg4vparse_handle_vo (parse, data + parse->vos_offset,
- parse->offset - parse->vos_offset);
+ parse->offset - parse->vos_offset, TRUE);
parse->state = PARSE_START_FOUND;
break;
default:
@@ -685,7 +700,8 @@ gst_mpeg4vparse_sink_setcaps (GstPad * pad, GstCaps * caps)
/* Sometimes, instead, it'll just have the video object/video object
layer data. We can parse that too, though it'll give us slightly
less information. */
- res = gst_mpeg4vparse_handle_vo (parse, data, GST_BUFFER_SIZE (buf));
+ res = gst_mpeg4vparse_handle_vo (parse, data, GST_BUFFER_SIZE (buf),
+ FALSE);
}
} else {
GST_WARNING_OBJECT (parse,