summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurélien Zanelli <aurelien.zanelli@parrot.com>2014-09-22 09:44:14 +0200
committerTim-Philipp Müller <tim@centricular.com>2014-10-24 22:09:56 +0100
commit907d17ef527bcec96fcf1856e8ef9924d3e954d8 (patch)
tree9fb1422adc428bf2f6f789b0380112829818f2fc
parent3a518bd1715c983b5127c18ad28494a54582fdbc (diff)
downloadgstreamer-plugins-bad-907d17ef527bcec96fcf1856e8ef9924d3e954d8.tar.gz
vc1parse: parse frame header when stream format is ASF/raw for simple/main profile
When stream-format is ASF or sequence-layer-raw-frame, we basically have a raw frame so we can parse it to extract some information such the keyframe flag. The only requirement is to have a valid sequence-header. This commit parse the frame header and set the DELTA_UNIT buffer flag in case the frame is not a keyframe. https://bugzilla.gnome.org/show_bug.cgi?id=738519
-rw-r--r--gst/videoparsers/gstvc1parse.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/gst/videoparsers/gstvc1parse.c b/gst/videoparsers/gstvc1parse.c
index 552ab3d69..406365975 100644
--- a/gst/videoparsers/gstvc1parse.c
+++ b/gst/videoparsers/gstvc1parse.c
@@ -863,6 +863,14 @@ gst_vc1_parse_update_caps (GstVC1Parse * vc1parse)
return TRUE;
}
+static inline void
+calculate_mb_size (GstVC1SeqHdr * seqhdr, guint width, guint height)
+{
+ seqhdr->mb_width = (width + 15) >> 4;
+ seqhdr->mb_height = (height + 15) >> 4;
+ seqhdr->mb_stride = seqhdr->mb_width + 1;
+}
+
static gboolean
gst_vc1_parse_handle_bdu (GstVC1Parse * vc1parse, GstVC1StartCode startcode,
GstBuffer * buffer, guint offset, guint size)
@@ -1173,6 +1181,34 @@ gst_vc1_parse_handle_frame (GstBaseParse * parse, GstBaseParseFrame * frame,
/* Must be a frame or a frame + field */
/* TODO: Check if keyframe */
}
+ } else {
+ /* In simple/main, we basically have a raw frame, so parse it */
+ GstVC1ParserResult pres;
+ GstVC1FrameHdr frame_hdr;
+ GstVC1SeqHdr seq_hdr;
+
+ if (!vc1parse->seq_hdr_buffer) {
+ /* Build seq_hdr from sequence-layer to be able to parse frame */
+ seq_hdr.profile = vc1parse->profile;
+ seq_hdr.struct_c = vc1parse->seq_layer.struct_c;
+ calculate_mb_size (&seq_hdr, vc1parse->seq_layer.struct_a.horiz_size,
+ vc1parse->seq_layer.struct_a.vert_size);
+ } else {
+ seq_hdr = vc1parse->seq_hdr;
+ }
+
+ pres = gst_vc1_parse_frame_header (data, size, &frame_hdr,
+ &seq_hdr, NULL);
+ if (pres != GST_VC1_PARSER_OK) {
+ GST_ERROR_OBJECT (vc1parse, "Invalid VC1 frame header");
+ ret = GST_FLOW_ERROR;
+ goto done;
+ }
+
+ if (frame_hdr.ptype == GST_VC1_PICTURE_TYPE_I)
+ GST_BUFFER_FLAG_UNSET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
+ else
+ GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT);
}
ret = GST_FLOW_OK;
} else {