aacparse: Fix parsing issue when the buffer does not have a complete ADTS/LOAS frame

https://bugzilla.gnome.org/show_bug.cgi?id=735520
This commit is contained in:
Nicolas Huet 2014-09-01 09:56:02 +02:00 committed by Sebastian Dröge
parent 9eb22a533b
commit 15894c1853

View File

@ -393,8 +393,10 @@ gst_aac_parse_check_adts_frame (GstAacParse * aacparse,
/* Absolute minimum to perform the ADTS syncword, /* Absolute minimum to perform the ADTS syncword,
layer and sampling frequency tests */ layer and sampling frequency tests */
if (G_UNLIKELY (avail < 3)) if (G_UNLIKELY (avail < 3)) {
*needed_data = 3;
return FALSE; return FALSE;
}
/* Syncword and layer tests */ /* Syncword and layer tests */
if ((data[0] == 0xff) && ((data[1] & 0xf6) == 0xf0)) { 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 = (data[1] & 0x01) ? 0 : 2;
/* CRC size test */ /* CRC size test */
if (*framesize < 7 + crc_size) if (*framesize < 7 + crc_size) {
*needed_data = 7 + crc_size;
return FALSE; return FALSE;
}
/* In EOS mode this is enough. No need to examine the data further. /* 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 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; *needed_data = 0;
/* 3 byte header */ /* 3 byte header */
if (G_UNLIKELY (avail < 3)) if (G_UNLIKELY (avail < 3)) {
*needed_data = 3;
return FALSE; return FALSE;
}
if ((data[0] == 0x56) && ((data[1] & 0xe0) == 0xe0)) { if ((data[0] == 0x56) && ((data[1] & 0xe0) == 0xe0)) {
*framesize = gst_aac_parse_loas_get_frame_len (data); *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, ret = gst_aac_parse_check_adts_frame (aacparse, map.data, map.size,
GST_BASE_PARSE_DRAINING (parse), &framesize, &needed_data); GST_BASE_PARSE_DRAINING (parse), &framesize, &needed_data);
if (!ret) { if (!ret && needed_data) {
GST_DEBUG ("buffer didn't contain valid frame"); GST_DEBUG ("buffer didn't contain valid frame");
*skipsize = 0;
gst_base_parse_set_min_frame_size (GST_BASE_PARSE (aacparse), gst_base_parse_set_min_frame_size (GST_BASE_PARSE (aacparse),
needed_data); needed_data);
} }
@ -1225,8 +1232,9 @@ gst_aac_parse_handle_frame (GstBaseParse * parse,
ret = gst_aac_parse_check_loas_frame (aacparse, map.data, ret = gst_aac_parse_check_loas_frame (aacparse, map.data,
map.size, GST_BASE_PARSE_DRAINING (parse), &framesize, &needed_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"); GST_DEBUG ("buffer didn't contain valid frame");
*skipsize = 0;
gst_base_parse_set_min_frame_size (GST_BASE_PARSE (aacparse), gst_base_parse_set_min_frame_size (GST_BASE_PARSE (aacparse),
needed_data); needed_data);
} }