summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeungha Yang <seungha@centricular.com>2021-09-14 17:26:27 +0900
committerSeungha Yang <seungha@centricular.com>2021-09-14 17:55:13 +0900
commit4576abde6754468835148d223f8bb124667d312e (patch)
tree011863b96069c32e1f9fe1c225478d7cb3310a8b
parent44bfc00884b6a48f81570bce7f4f93ed46d552de (diff)
downloadgstreamer-plugins-good-4576abde6754468835148d223f8bb124667d312e.tar.gz
qtdemux: Try to build AAC codec-data whenever it's possible
AAC codec_data is a just collection of AAC profile, samplerate, and channels. We can know samplerate and channels from parsed SampleEntry data. Although the AAC profile is unknown there, let's assume it as AAC-LC like we've been doing for the version 1 atom. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/1082>
-rw-r--r--gst/isomp4/qtdemux.c56
1 files changed, 35 insertions, 21 deletions
diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c
index 15c1e7da2..a1a2b918a 100644
--- a/gst/isomp4/qtdemux.c
+++ b/gst/isomp4/qtdemux.c
@@ -12730,32 +12730,46 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak)
{
/* mp4a atom withtout ESDS; Attempt to build codec data from atom */
gint len = QT_UINT32 (stsd_entry_data);
+ guint16 sound_version = 0;
+ /* FIXME: Can this be determined somehow? There doesn't seem to be
+ * anything in mp4a atom that specifis compression */
+ gint profile = 2;
+ guint16 channels = entry->n_channels;
+ guint32 time_scale = (guint32) entry->rate;
+ gint sample_rate_index = -1;
if (len >= 34) {
- guint16 sound_version = QT_UINT16 (stsd_entry_data + 16);
+ sound_version = QT_UINT16 (stsd_entry_data + 16);
if (sound_version == 1) {
- guint16 channels = QT_UINT16 (stsd_entry_data + 24);
- guint32 time_scale = QT_UINT32 (stsd_entry_data + 30);
- guint8 codec_data[2];
- GstBuffer *buf;
- gint profile = 2; /* FIXME: Can this be determined somehow? There doesn't seem to be anything in mp4a atom that specifis compression */
-
- gint sample_rate_index =
- gst_codec_utils_aac_get_index_from_sample_rate (time_scale);
-
- /* build AAC codec data */
- codec_data[0] = profile << 3;
- codec_data[0] |= ((sample_rate_index >> 1) & 0x7);
- codec_data[1] = (sample_rate_index & 0x01) << 7;
- codec_data[1] |= (channels & 0xF) << 3;
-
- buf = gst_buffer_new_and_alloc (2);
- gst_buffer_fill (buf, 0, codec_data, 2);
- gst_caps_set_simple (entry->caps,
- "codec_data", GST_TYPE_BUFFER, buf, NULL);
- gst_buffer_unref (buf);
+ channels = QT_UINT16 (stsd_entry_data + 24);
+ time_scale = QT_UINT32 (stsd_entry_data + 30);
+ } else {
+ GST_FIXME_OBJECT (qtdemux, "Unhandled mp4a atom version %d",
+ sound_version);
}
+ } else {
+ GST_DEBUG_OBJECT (qtdemux, "Too small stsd entry data len %d",
+ len);
+ }
+
+ sample_rate_index =
+ gst_codec_utils_aac_get_index_from_sample_rate (time_scale);
+ if (sample_rate_index >= 0 && channels > 0) {
+ guint8 codec_data[2];
+ GstBuffer *buf;
+
+ /* build AAC codec data */
+ codec_data[0] = profile << 3;
+ codec_data[0] |= ((sample_rate_index >> 1) & 0x7);
+ codec_data[1] = (sample_rate_index & 0x01) << 7;
+ codec_data[1] |= (channels & 0xF) << 3;
+
+ buf = gst_buffer_new_and_alloc (2);
+ gst_buffer_fill (buf, 0, codec_data, 2);
+ gst_caps_set_simple (entry->caps,
+ "codec_data", GST_TYPE_BUFFER, buf, NULL);
+ gst_buffer_unref (buf);
}
break;
}