diff options
author | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2009-10-28 14:08:43 +0100 |
---|---|---|
committer | Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk> | 2009-12-08 16:06:31 +0100 |
commit | 9eae24835e4c2a0cd54cfe4c100db29fbbd1b545 (patch) | |
tree | 1615cbad28da13ba48391490a61e95d476262ae4 | |
parent | bb8085a34867c58d90a0384fc47d077064b85dc4 (diff) |
ac3parse: perform additional frame checks when resyncing
-rw-r--r-- | gst/audioparsers/gstac3parse.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/gst/audioparsers/gstac3parse.c b/gst/audioparsers/gstac3parse.c index d87228b1a..b2bfb0a43 100644 --- a/gst/audioparsers/gstac3parse.c +++ b/gst/audioparsers/gstac3parse.c @@ -372,6 +372,7 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse, GstBuffer * buf, GstByteReader reader = GST_BYTE_READER_INIT_FROM_BUFFER (buf); GstAc3Parse *ac3parse = GST_AC3_PARSE (parse); gint off; + gboolean sync, drain; off = gst_byte_reader_masked_scan_uint32 (&reader, 0xffff0000, 0x0b770000, 0, GST_BUFFER_SIZE (buf)); @@ -397,7 +398,33 @@ gst_ac3_parse_check_valid_frame (GstBaseParse * parse, GstBuffer * buf, } GST_LOG_OBJECT (parse, "got frame"); - /* FIXME: do further/better checks here? */ + + sync = gst_base_parse_get_sync (parse); + drain = gst_base_parse_get_drain (parse); + + if (!sync && !drain) { + guint16 word; + + GST_DEBUG_OBJECT (ac3parse, "resyncing; checking next frame syncword"); + + if (!gst_byte_reader_skip (&reader, *framesize) || + !gst_byte_reader_get_uint16_be (&reader, &word)) { + GST_DEBUG_OBJECT (ac3parse, "... but not sufficient data"); + gst_base_parse_set_min_frame_size (parse, *framesize + 6); + *skipsize = 0; + return FALSE; + } else { + if (word != 0x0b77) { + GST_DEBUG_OBJECT (ac3parse, "0x%x not OK", word); + *skipsize = off + 2; + return FALSE; + } else { + /* ok, got sync now, let's assume constant frame size */ + gst_base_parse_set_min_frame_size (parse, *framesize); + } + } + } + return TRUE; } |