summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Huet <nicolas.huet@parrot.com>2014-09-01 09:56:02 +0200
committerSebastian Dröge <sebastian@centricular.com>2014-09-04 12:54:25 +0300
commit241a634570a9905fa380636472c11b7274452aef (patch)
tree027fa36f1ecf47c7389361e4d1107d8511bf8636
parent4d91ecc365d32033b9e7acadc31141829da17670 (diff)
aacparse: Fix parsing issue when the buffer does not have a complete ADTS/LOAS frame
https://bugzilla.gnome.org/show_bug.cgi?id=735520
-rw-r--r--gst/audioparsers/gstaacparse.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/gst/audioparsers/gstaacparse.c b/gst/audioparsers/gstaacparse.c
index 2a37c378f..97b7f3e41 100644
--- a/gst/audioparsers/gstaacparse.c
+++ b/gst/audioparsers/gstaacparse.c
@@ -393,8 +393,10 @@ gst_aac_parse_check_adts_frame (GstAacParse * aacparse,
/* Absolute minimum to perform the ADTS syncword,
layer and sampling frequency tests */
- if (G_UNLIKELY (avail < 3))
+ if (G_UNLIKELY (avail < 3)) {
+ *needed_data = 3;
return FALSE;
+ }
/* Syncword and layer tests */
if ((data[0] == 0xff) && ((data[1] & 0xf6) == 0xf0)) {
@@ -417,8 +419,10 @@ gst_aac_parse_check_adts_frame (GstAacParse * aacparse,
crc_size = (data[1] & 0x01) ? 0 : 2;
/* CRC size test */
- if (*framesize < 7 + crc_size)
+ if (*framesize < 7 + crc_size) {
+ *needed_data = 7 + crc_size;
return FALSE;
+ }
/* In EOS mode this is enough. No need to examine the data further.
We also relax the check when we have sync, on the assumption that
@@ -701,8 +705,10 @@ gst_aac_parse_check_loas_frame (GstAacParse * aacparse,
*needed_data = 0;
/* 3 byte header */
- if (G_UNLIKELY (avail < 3))
+ if (G_UNLIKELY (avail < 3)) {
+ *needed_data = 3;
return FALSE;
+ }
if ((data[0] == 0x56) && ((data[1] & 0xe0) == 0xe0)) {
*framesize = gst_aac_parse_loas_get_frame_len (data);
@@ -1213,8 +1219,9 @@ gst_aac_parse_handle_frame (GstBaseParse * parse,
ret = gst_aac_parse_check_adts_frame (aacparse, map.data, map.size,
GST_BASE_PARSE_DRAINING (parse), &framesize, &needed_data);
- if (!ret) {
+ if (!ret && needed_data) {
GST_DEBUG ("buffer didn't contain valid frame");
+ *skipsize = 0;
gst_base_parse_set_min_frame_size (GST_BASE_PARSE (aacparse),
needed_data);
}
@@ -1225,8 +1232,9 @@ gst_aac_parse_handle_frame (GstBaseParse * parse,
ret = gst_aac_parse_check_loas_frame (aacparse, map.data,
map.size, GST_BASE_PARSE_DRAINING (parse), &framesize, &needed_data);
- if (!ret) {
+ if (!ret && needed_data) {
GST_DEBUG ("buffer didn't contain valid frame");
+ *skipsize = 0;
gst_base_parse_set_min_frame_size (GST_BASE_PARSE (aacparse),
needed_data);
}