From 4c7fd3c247f43d82e6d4688d29207eb1fdd5ee91 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Tue, 22 Jun 2010 12:28:38 +0200 Subject: [PATCH] h264parse: add new h264 caps attribute alignment See #606662. --- gst/h264parse/gsth264parse.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/gst/h264parse/gsth264parse.c b/gst/h264parse/gsth264parse.c index 1f8b924778..d2e539029a 100644 --- a/gst/h264parse/gsth264parse.c +++ b/gst/h264parse/gsth264parse.c @@ -1202,7 +1202,7 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps) GstCaps *src_caps = NULL; GstStructure *structure; gboolean modified = FALSE; - const gchar *stream_format; + const gchar *stream_format, *alignment; /* current PPS dictates which SPS to use */ if (h264parse->pps && h264parse->pps->sps_id < MAX_SPS_COUNT) { @@ -1303,6 +1303,38 @@ gst_h264_parse_update_src_caps (GstH264Parse * h264parse, GstCaps * caps) modified = TRUE; } + /* set alignment field */ + if (h264parse->merge) { + alignment = "au"; + } else { + if (h264parse->packetized) { + /* if packetized input, take upstream alignment if validly provided, + * otherwise assume au aligned ... */ + alignment = gst_structure_get_string (structure, "alignment"); + if (!alignment || (alignment && + strcmp (alignment, "au") != 0 && + strcmp (alignment, "nal") != 0)) { + if (h264parse->split_packetized) + alignment = "nal"; + else + alignment = "au"; + } + } else { + alignment = "nal"; + } + } + /* now only set if changed */ + { + const gchar *old_alignment; + + old_alignment = gst_structure_get_string (structure, "alignment"); + if (!old_alignment || strcmp (alignment, old_alignment) != 0) { + gst_structure_set (structure, "alignment", G_TYPE_STRING, alignment, + NULL); + modified = TRUE; + } + } + /* transforming to non-bytestream needs to make codec-data */ if (h264parse->format == GST_H264_PARSE_FORMAT_SAMPLE) { GstBuffer *buf;