diff --git a/ext/fdkaac/gstfdkaac.c b/ext/fdkaac/gstfdkaac.c new file mode 100644 index 0000000000..1b109926d0 --- /dev/null +++ b/ext/fdkaac/gstfdkaac.c @@ -0,0 +1,248 @@ +/* + * Copyright (C) 2016 Sebastian Dröge + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "gstfdkaac.h" +#include "gstfdkaacenc.h" +#include "gstfdkaacdec.h" + +/* *INDENT-OFF* */ +const GstFdkAacChannelLayout channel_layouts[] = { + /* MPEG 1: Mono */ + {1, MODE_1, {GST_AUDIO_CHANNEL_POSITION_MONO}}, + /* MPEG 2: Stereo */ + {2, MODE_2, { + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + }}, + /* MPEG 3: Stereo + Center */ + {3, MODE_1_2, { + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + }}, + /* MPEG 4: Stereo + Center + Rear center */ + {4, MODE_1_2_1, { + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_CENTER, + }}, + /* MPEG 5: 5.0 Surround */ + {5, MODE_1_2_2, { /* Informal, with REAR */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, + GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, + }}, + {5, MODE_1_2_2, { /* Formal, with SURROUND */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT, + GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT, + }}, + {5, MODE_1_2_2, { /* Informal, with SIDE; FFmpeg produces this */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT, + GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT, + }}, + /* MPEG 6: 5.1 Surround */ + {6, MODE_1_2_2_1, { /* Informal, with REAR */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, + GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, + GST_AUDIO_CHANNEL_POSITION_LFE1, + }}, + {6, MODE_1_2_2_1, { /* Formal, with SURROUND */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT, + GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT, + GST_AUDIO_CHANNEL_POSITION_LFE1, + }}, + {6, MODE_1_2_2_1, { /* Informal, with SIDE; FFmpeg produces this */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT, + GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT, + GST_AUDIO_CHANNEL_POSITION_LFE1, + }}, + /* MPEG 7: SDDS for cinema */ + {8, MODE_1_2_2_2_1, { /* Informal, with REAR */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, + GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, + GST_AUDIO_CHANNEL_POSITION_LFE1, + }}, + {8, MODE_1_2_2_2_1, { /* Formal, with SURROUND */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT, + GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT, + GST_AUDIO_CHANNEL_POSITION_LFE1, + }}, + /* Note: 8-channel layouts might also have informal variants with + * SIDE instead of SURROUND, but they are more complicated. They + * can be added here if the need arises */ +#ifdef HAVE_FDK_AAC_2_0_0 + /* MPEG 11: 6.1 Surround */ + {7, MODE_6_1, { /* Informal, with REAR */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, + GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_CENTER, + GST_AUDIO_CHANNEL_POSITION_LFE1, + }}, + {7, MODE_6_1, { /* Formal, with SURROUND */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT, + GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_CENTER, + GST_AUDIO_CHANNEL_POSITION_LFE1, + }}, + /* MPEG 12: 7.1 Surround */ + {8, MODE_7_1_BACK, { /* Informal, with SIDE */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT, + GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, + GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, + GST_AUDIO_CHANNEL_POSITION_LFE1, + }}, + {8, MODE_7_1_BACK, { /* Formal, with SURROUND */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT, + GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, + GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, + GST_AUDIO_CHANNEL_POSITION_LFE1, + }}, + /* MPEG 14: 5.1.2 Surround */ + {8, MODE_7_1_TOP_FRONT, { /* Informal, with REAR */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, + GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, + GST_AUDIO_CHANNEL_POSITION_LFE1, + GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_RIGHT, + }}, + {8, MODE_7_1_TOP_FRONT, { /* Formal, with SURROUND */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT, + GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT, + GST_AUDIO_CHANNEL_POSITION_LFE1, + GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_RIGHT, + }}, +#endif +#ifdef HAVE_FDK_AAC_0_1_4 + /* Non-standard PCE clone of mode 12 */ + {8, MODE_7_1_REAR_SURROUND, { /* Informal, with SIDE */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT, + GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, + GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, + GST_AUDIO_CHANNEL_POSITION_LFE1, + }}, + {8, MODE_7_1_REAR_SURROUND, { /* Formal, with SURROUND */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT, + GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, + GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, + GST_AUDIO_CHANNEL_POSITION_LFE1, + }}, + /* Non-standard PCE clone of mode 7 */ + {8, MODE_7_1_FRONT_CENTER,{ /* Informal, with REAR */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, + GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, + GST_AUDIO_CHANNEL_POSITION_LFE1, + }}, + {8, MODE_7_1_FRONT_CENTER, { /* Formal, with SURROUND */ + GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER, + GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, + GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, + GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT, + GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT, + GST_AUDIO_CHANNEL_POSITION_LFE1, + }}, +#endif + /* Iteration sentinel */ + {0, MODE_INVALID, {GST_AUDIO_CHANNEL_POSITION_INVALID}}, +}; +/* *INDENT-ON* */ + +static gboolean +plugin_init (GstPlugin * plugin) +{ + return gst_element_register (plugin, "fdkaacenc", GST_RANK_PRIMARY, + GST_TYPE_FDKAACENC) + && gst_element_register (plugin, "fdkaacdec", GST_RANK_MARGINAL, + GST_TYPE_FDKAACDEC); +} + +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, + GST_VERSION_MINOR, + fdkaac, + "Fraunhofer FDK AAC Codec plugin", + plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN) diff --git a/ext/fdkaac/gstfdkaac.h b/ext/fdkaac/gstfdkaac.h new file mode 100644 index 0000000000..c2030e9c5c --- /dev/null +++ b/ext/fdkaac/gstfdkaac.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 LTN Global Communications, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __GST_FDKAAC_H__ +#define __GST_FDKAAC_H__ + +#include + +#include + +G_BEGIN_DECLS + +typedef struct { + gint channels; + CHANNEL_MODE mode; + GstAudioChannelPosition positions[8]; +} GstFdkAacChannelLayout; + +extern const GstFdkAacChannelLayout channel_layouts[]; + +G_END_DECLS + +#endif /* __GST_FDKAAC_H__ */ diff --git a/ext/fdkaac/gstfdkaacenc.c b/ext/fdkaac/gstfdkaacenc.c index 3310f53eef..867193f2b0 100644 --- a/ext/fdkaac/gstfdkaacenc.c +++ b/ext/fdkaac/gstfdkaacenc.c @@ -21,6 +21,7 @@ #include "config.h" #endif +#include "gstfdkaac.h" #include "gstfdkaacenc.h" #include @@ -55,199 +56,6 @@ enum "88200, " \ "96000" -/* *INDENT-OFF* */ -static const struct -{ - gint channels; - CHANNEL_MODE mode; - GstAudioChannelPosition positions[8]; -} channel_layouts[] = { - { - /* MPEG 1: Mono */ - 1, MODE_1, { - GST_AUDIO_CHANNEL_POSITION_MONO}}, { - /* MPEG 2: Stereo */ - 2, MODE_2, { - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}}, { - /* MPEG 3: Stereo + Center */ - 3, MODE_1_2, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT}}, { - /* MPEG 4: Stereo + Center + Rear center */ - 4, MODE_1_2_1, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_REAR_CENTER}}, { - /* MPEG 5: 5.0 Surround */ - 5, MODE_1_2_2, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, - GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT}}, { - 5, MODE_1_2_2, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT, - GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT}}, { - /* MPEG 5: 5.0 Surround with SIDE (ffmpeg produces this) */ - 5, MODE_1_2_2, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT, - GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT}}, { - /* MPEG 6: 5.1 Surround */ - 6, MODE_1_2_2_1, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, - GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, - GST_AUDIO_CHANNEL_POSITION_LFE1}}, { - 6, MODE_1_2_2_1, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT, - GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT, - GST_AUDIO_CHANNEL_POSITION_LFE1}}, { - /* MPEG 6: 5.1 Surround with SIDE (ffmpeg produces this) */ - 6, MODE_1_2_2_1, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT, - GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT, - GST_AUDIO_CHANNEL_POSITION_LFE1}}, { - /* Note: 8-channel layouts might also have informal variants with - * SIDE instead of SURROUND, but they are more complicated. They - * can be added here if the need arises */ - /* MPEG 7: SDDS for cinema */ - 8, MODE_1_2_2_2_1, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, - GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, - GST_AUDIO_CHANNEL_POSITION_LFE1}}, { - 8, MODE_1_2_2_2_1, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT, - GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT, - GST_AUDIO_CHANNEL_POSITION_LFE1}} -#ifdef HAVE_FDK_AAC_2_0_0 - , { - /* MPEG 11: 6.1 Surround */ - 7, MODE_6_1, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, - GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, - GST_AUDIO_CHANNEL_POSITION_REAR_CENTER, - GST_AUDIO_CHANNEL_POSITION_LFE1}}, { - 7, MODE_6_1, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT, - GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT, - GST_AUDIO_CHANNEL_POSITION_REAR_CENTER, - GST_AUDIO_CHANNEL_POSITION_LFE1}}, { - /* MPEG 12: 7.1 Surround */ - 8, MODE_7_1_BACK, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT, - GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT, - GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, - GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, - GST_AUDIO_CHANNEL_POSITION_LFE1}}, { - 8, MODE_7_1_BACK, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT, - GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT, - GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, - GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, - GST_AUDIO_CHANNEL_POSITION_LFE1}}, { - /* MPEG 14: 5.1.2 Surround */ - 8, MODE_7_1_TOP_FRONT, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, - GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, - GST_AUDIO_CHANNEL_POSITION_LFE1, - GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_RIGHT}}, { - 8, MODE_7_1_TOP_FRONT, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT, - GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT, - GST_AUDIO_CHANNEL_POSITION_LFE1, - GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_TOP_FRONT_RIGHT}} -#endif -#ifdef HAVE_FDK_AAC_0_1_4 - , { - /* Non-standard PCE clone of mode 12 */ - 8, MODE_7_1_REAR_SURROUND, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT, - GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT, - GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, - GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, - GST_AUDIO_CHANNEL_POSITION_LFE1}}, { - 8, MODE_7_1_REAR_SURROUND, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT, - GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT, - GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, - GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, - GST_AUDIO_CHANNEL_POSITION_LFE1}}, { - /* Non-standard PCE clone of mode 7 */ - 8, MODE_7_1_FRONT_CENTER, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_REAR_LEFT, - GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT, - GST_AUDIO_CHANNEL_POSITION_LFE1}}, { - 8, MODE_7_1_FRONT_CENTER, { - GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER, - GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT, - GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT, - GST_AUDIO_CHANNEL_POSITION_SURROUND_LEFT, - GST_AUDIO_CHANNEL_POSITION_SURROUND_RIGHT, - GST_AUDIO_CHANNEL_POSITION_LFE1}} -#endif -}; -/* *INDENT-ON* */ - static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, @@ -347,25 +155,24 @@ gst_fdkaacenc_stop (GstAudioEncoder * enc) static GstCaps * gst_fdkaacenc_get_caps (GstAudioEncoder * enc, GstCaps * filter) { + const GstFdkAacChannelLayout *layout; GstCaps *res, *caps; - gint i; caps = gst_caps_new_empty (); - for (i = 0; i < G_N_ELEMENTS (channel_layouts); i++) { + for (layout = channel_layouts; layout->channels; layout++) { guint64 channel_mask; GstCaps *tmp = gst_caps_make_writable (gst_pad_get_pad_template_caps (GST_AUDIO_ENCODER_SINK_PAD (enc))); - if (channel_layouts[i].channels == 1) { - gst_caps_set_simple (tmp, "channels", G_TYPE_INT, - channel_layouts[i].channels, NULL); + if (layout->channels == 1) { + gst_caps_set_simple (tmp, "channels", G_TYPE_INT, layout->channels, NULL); } else { - gst_audio_channel_positions_to_mask (channel_layouts[i].positions, - channel_layouts[i].channels, FALSE, &channel_mask); + gst_audio_channel_positions_to_mask (layout->positions, + layout->channels, FALSE, &channel_mask); gst_caps_set_simple (tmp, "channels", G_TYPE_INT, - channel_layouts[i].channels, "channel-mask", GST_TYPE_BITMASK, + layout->channels, "channel-mask", GST_TYPE_BITMASK, channel_mask, NULL); } @@ -450,29 +257,29 @@ gst_fdkaacenc_set_format (GstAudioEncoder * enc, GstAudioInfo * info) self->aac_positions = NULL; } else { guint64 in_channel_mask, out_channel_mask; - gint i; + const GstFdkAacChannelLayout *layout; - for (i = 0; i < G_N_ELEMENTS (channel_layouts); i++) { - if (channel_layouts[i].channels != GST_AUDIO_INFO_CHANNELS (info)) + for (layout = channel_layouts; layout->channels; layout++) { + if (layout->channels != GST_AUDIO_INFO_CHANNELS (info)) continue; gst_audio_channel_positions_to_mask (&GST_AUDIO_INFO_POSITION (info, 0), GST_AUDIO_INFO_CHANNELS (info), FALSE, &in_channel_mask); - gst_audio_channel_positions_to_mask (channel_layouts[i].positions, - channel_layouts[i].channels, FALSE, &out_channel_mask); + gst_audio_channel_positions_to_mask (layout->positions, + layout->channels, FALSE, &out_channel_mask); if (in_channel_mask == out_channel_mask) { - channel_mode = channel_layouts[i].mode; + channel_mode = layout->mode; self->need_reorder = - memcmp (channel_layouts[i].positions, + memcmp (layout->positions, &GST_AUDIO_INFO_POSITION (info, 0), GST_AUDIO_INFO_CHANNELS (info) * sizeof (GstAudioChannelPosition)) != 0; - self->aac_positions = channel_layouts[i].positions; + self->aac_positions = layout->positions; break; } } - if (i == G_N_ELEMENTS (channel_layouts)) { + if (!layout->channels) { GST_ERROR_OBJECT (self, "Couldn't find a valid channel layout"); return FALSE; } diff --git a/ext/fdkaac/meson.build b/ext/fdkaac/meson.build index fee7498cf2..d2781c86fe 100644 --- a/ext/fdkaac/meson.build +++ b/ext/fdkaac/meson.build @@ -14,7 +14,7 @@ if fdkaac_dep.found() endif gstfdkaac = library('gstfdkaac', - ['plugin.c', 'gstfdkaacenc.c', 'gstfdkaacdec.c'], + ['gstfdkaac.c', 'gstfdkaacenc.c', 'gstfdkaacdec.c'], c_args : gst_plugins_bad_args + fdkaac_defines, include_directories : [configinc], dependencies : [gstaudio_dep, gstpbutils_dep, fdkaac_dep], diff --git a/ext/fdkaac/plugin.c b/ext/fdkaac/plugin.c deleted file mode 100644 index e3aadec43f..0000000000 --- a/ext/fdkaac/plugin.c +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2016 Sebastian Dröge - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include "gstfdkaacenc.h" -#include "gstfdkaacdec.h" - -static gboolean -plugin_init (GstPlugin * plugin) -{ - return gst_element_register (plugin, "fdkaacenc", GST_RANK_PRIMARY, - GST_TYPE_FDKAACENC) - && gst_element_register (plugin, "fdkaacdec", GST_RANK_MARGINAL, - GST_TYPE_FDKAACDEC); -} - -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, - GST_VERSION_MINOR, - fdkaac, - "Fraunhofer FDK AAC Codec plugin", - plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)