qtmux: Allow MPEG-1 Layer 1 and 2 in addition to 3 in MP4

Via the MPEG-4 Part 3 spec we can support the other layers too.
Also correct the samples per frame calculation for MP3 if it's MPEG-2 or
MPEG-2.5.

https://bugzilla.gnome.org/show_bug.cgi?id=765725
This commit is contained in:
Sebastian Dröge 2016-04-28 16:24:52 +03:00
parent 7c728db1f3
commit f8b87c8a05
2 changed files with 32 additions and 18 deletions

View file

@ -3461,30 +3461,38 @@ gst_qt_mux_audio_sink_set_caps (GstQTPad * qtpad, GstCaps * caps)
/* now map onto a fourcc, and some extra properties */
if (strcmp (mimetype, "audio/mpeg") == 0) {
gint mpegversion = 0;
gint mpegversion = 0, mpegaudioversion = 0;
gint layer = -1;
gst_structure_get_int (structure, "mpegversion", &mpegversion);
switch (mpegversion) {
case 1:
gst_structure_get_int (structure, "layer", &layer);
switch (layer) {
case 3:
/* mp3 */
/* note: QuickTime player does not like mp3 either way in iso/mp4 */
if (format == GST_QT_MUX_FORMAT_QT)
entry.fourcc = FOURCC__mp3;
else {
entry.fourcc = FOURCC_mp4a;
ext_atom =
build_esds_extension (qtpad->trak, ESDS_OBJECT_TYPE_MPEG1_P3,
ESDS_STREAM_TYPE_AUDIO, codec_data, qtpad->avg_bitrate,
qtpad->max_bitrate);
}
entry.samples_per_packet = 1152;
entry.bytes_per_sample = 2;
break;
gst_structure_get_int (structure, "mpegaudioversion",
&mpegaudioversion);
/* mp1/2/3 */
/* note: QuickTime player does not like mp3 either way in iso/mp4 */
if (format == GST_QT_MUX_FORMAT_QT)
entry.fourcc = FOURCC__mp3;
else {
entry.fourcc = FOURCC_mp4a;
ext_atom =
build_esds_extension (qtpad->trak, ESDS_OBJECT_TYPE_MPEG1_P3,
ESDS_STREAM_TYPE_AUDIO, codec_data, qtpad->avg_bitrate,
qtpad->max_bitrate);
}
if (layer == 1) {
g_warn_if_fail (format == GST_QT_MUX_FORMAT_MP4);
entry.samples_per_packet = 384;
} else if (layer == 2) {
g_warn_if_fail (format == GST_QT_MUX_FORMAT_MP4);
entry.samples_per_packet = 1152;
} else {
g_warn_if_fail (layer == 3);
entry.samples_per_packet = (mpegaudioversion <= 1) ? 1152 : 576;
}
entry.bytes_per_sample = 2;
break;
case 4:

View file

@ -104,6 +104,12 @@
"layer = (int) 3, " \
COMMON_AUDIO_CAPS (2, MAX)
#define MP123_CAPS \
"audio/mpeg, " \
"mpegversion = (int) 1, " \
"layer = (int) [1, 3], " \
COMMON_AUDIO_CAPS (2, MAX)
#define AAC_CAPS \
"audio/mpeg, " \
"mpegversion = (int) 4, " \
@ -190,7 +196,7 @@ GstQTMuxFormatProp gst_qt_mux_format_list[] = {
GST_STATIC_CAPS ("video/quicktime, variant = (string) iso"),
GST_STATIC_CAPS (MPEG4V_CAPS "; " H264_CAPS ";"
"video/x-mp4-part," COMMON_VIDEO_CAPS),
GST_STATIC_CAPS (MP3_CAPS "; "
GST_STATIC_CAPS (MP123_CAPS "; "
AAC_CAPS " ; " AC3_CAPS " ; " ALAC_CAPS " ; " OPUS_CAPS),
GST_STATIC_CAPS (TEXT_UTF8)}
,