aacparse: When parsing raw input, accept frames of any size

Raw AAC streams might have very small frames, e.g. 6 byte frames
when encoding silence. These frames are then smaller than aacparse's
default min_frame_size of 10 bytes (ADTS_MAX_SIZE).

When passthrough is disabled or aacparse has to output ADTS, GstBaseParse
will concatenate these short frames to the following frame before
handling them to aacparse, which processes each input buffer as a single
frame, producing bad output.

To avoid this problem, set the min_frame_size to 1 when receiving a raw
stream.

https://bugzilla.gnome.org/show_bug.cgi?id=792644
This commit is contained in:
Jan Alexander Steffens (heftig) 2018-01-18 14:23:07 +01:00 committed by Tim-Philipp Müller
parent c019530091
commit e273e5f7a6

View file

@ -68,6 +68,7 @@ GST_DEBUG_CATEGORY_STATIC (aacparse_debug);
#define ADIF_MAX_SIZE 40 /* Should be enough */
#define ADTS_MAX_SIZE 10 /* Should be enough */
#define LOAS_MAX_SIZE 3 /* Should be enough */
#define RAW_MAX_SIZE 1 /* Correct framing is required */
#define ADTS_HEADERS_LENGTH 7UL /* Total byte-length of fixed and variable
headers prepended during raw to ADTS
@ -334,6 +335,9 @@ gst_aac_parse_sink_setcaps (GstBaseParse * parse, GstCaps * caps)
gst_aac_parse_set_src_caps (aacparse, caps);
if (aacparse->header_type == aacparse->output_header_type)
gst_base_parse_set_passthrough (parse, TRUE);
/* input is already correctly framed */
gst_base_parse_set_min_frame_size (parse, RAW_MAX_SIZE);
} else {
return FALSE;
}