Remove twolame plugin, moved to -good

https://bugzilla.gnome.org/show_bug.cgi?id=774252
This commit is contained in:
Tim-Philipp Müller 2017-08-26 09:35:20 +01:00
parent b40e1a76b8
commit aa14b72a99
14 changed files with 2 additions and 1081 deletions

View file

@ -42,6 +42,7 @@ CRUFT_FILES = \
$(top_builddir)/common/shave-libtool \
$(top_builddir)/ext/mpg123/.libs/libgstmpg123.so \
$(top_builddir)/ext/lame/.libs/libgstlame.so \
$(top_builddir)/ext/twolame/.libs/libgsttwolame.so \
$(top_builddir)/gst/realmedia/.libs/libgstrmdemux.so
CRUFT_DIRS = \
@ -49,6 +50,7 @@ CRUFT_DIRS = \
$(top_srcdir)/docs/plugins/tmpl \
$(top_srcdir)/ext/mpg123/ \
$(top_srcdir)/ext/lame/ \
$(top_srcdir)/ext/twolame/ \
$(top_builddir)/win32 \
$(top_srcdir)/win32

View file

@ -45,6 +45,4 @@ cdio (for the cdio CDDA CD audio source)
http://savannah.gnu.org/projects/libcdio/
x264 (for the x264enc H.264 encoder)
http://www.videolan.org/developers/x264.html
twolame (for the twolame mp2 encoder)
http://www.twolame.org/
sidplay FIXME

View file

@ -289,17 +289,6 @@ AG_GST_CHECK_FEATURE(SIDPLAY, [libsidplay], sid, [
GST_PATH_SIDPLAY()
])
dnl *** twolame ***
translit(dnm, m, l) AM_CONDITIONAL(USE_TWOLAME, true)
AG_GST_CHECK_FEATURE(TWOLAME, [twolame], twolame, [
PKG_CHECK_MODULES(TWOLAME, twolame >= 0.3.10, [
HAVE_TWOLAME="yes"], [
HAVE_TWOLAME="no"
])
AC_SUBST(TWOLAME_CFLAGS)
AC_SUBST(TWOLAME_LIBS)
])
dnl *** x264 (MPEG-4 part 10/h.264/AVC encoder) ***
translit(dnm, m, l) AM_CONDITIONAL(USE_X264, true)
AG_GST_CHECK_FEATURE(X264, [x264 plug-in], x264, [
@ -329,7 +318,6 @@ AM_CONDITIONAL(USE_CDIO, false)
AM_CONDITIONAL(USE_DVDREAD, false)
AM_CONDITIONAL(USE_MPEG2DEC, false)
AM_CONDITIONAL(USE_SIDPLAY, false)
AM_CONDITIONAL(USE_TWOLAME, false)
AM_CONDITIONAL(USE_X264, false)
fi dnl of EXT plugins
@ -411,7 +399,6 @@ ext/cdio/Makefile
ext/dvdread/Makefile
ext/mpeg2dec/Makefile
ext/sidplay/Makefile
ext/twolame/Makefile
ext/x264/Makefile
docs/Makefile
docs/plugins/Makefile

View file

@ -60,7 +60,6 @@ EXTRA_HFILES = \
$(top_srcdir)/ext/amrwbdec/amrwbdec.h \
$(top_srcdir)/ext/cdio/gstcdiocddasrc.h \
$(top_srcdir)/ext/sidplay/gstsiddec.h \
$(top_srcdir)/ext/twolame/gsttwolamemp2enc.h \
$(top_srcdir)/ext/x264/gstx264enc.h \
$(top_srcdir)/gst/asfdemux/gstrtspwms.h \
$(top_srcdir)/gst/xingmux/gstxingmux.h \

View file

@ -28,7 +28,6 @@
<xi:include href="xml/element-rtspreal.xml" />
<xi:include href="xml/element-rtspwms.xml" />
<xi:include href="xml/element-siddec.xml" />
<xi:include href="xml/element-twolamemp2enc.xml" />
<xi:include href="xml/element-x264enc.xml" />
<xi:include href="xml/element-xingmux.xml" />
</chapter>
@ -46,7 +45,6 @@
<xi:include href="xml/plugin-mpeg2dec.xml" />
<xi:include href="xml/plugin-realmedia.xml" />
<xi:include href="xml/plugin-siddec.xml" />
<xi:include href="xml/plugin-twolame.xml" />
<xi:include href="xml/plugin-x264.xml" />
</chapter>
</book>

View file

@ -187,21 +187,6 @@ GST_TYPE_SIDDEC
gst_siddec_get_type
</SECTION>
<SECTION>
<FILE>element-twolamemp2enc</FILE>
<TITLE>twolame</TITLE>
GstTwoLame
<SUBSECTION Standard>
GstTwoLameClass
GST_TWO_LAME
GST_TWO_LAME_CLASS
GST_IS_TWO_LAME
GST_IS_TWO_LAME_CLASS
GST_TYPE_TWO_LAME
gst_two_lame_get_type
</SECTION>
<SECTION>
<FILE>element-x264enc</FILE>
<TITLE>x264enc</TITLE>

View file

@ -1,34 +0,0 @@
<plugin>
<name>twolame</name>
<description>Encode MP2s with TwoLAME</description>
<filename>../../ext/twolame/.libs/libgsttwolame.so</filename>
<basename>libgsttwolame.so</basename>
<version>1.12.0</version>
<license>LGPL</license>
<source>gst-plugins-ugly</source>
<package>GStreamer Ugly Plug-ins source release</package>
<origin>Unknown package origin</origin>
<elements>
<element>
<name>twolamemp2enc</name>
<longname>TwoLAME mp2 encoder</longname>
<class>Codec/Encoder/Audio</class>
<description>High-quality free MP2 encoder</description>
<author>Sebastian Dröge &lt;sebastian.droege@collabora.co.uk&gt;</author>
<pads>
<caps>
<name>sink</name>
<direction>sink</direction>
<presence>always</presence>
<details>audio/x-raw, format=(string){ F32LE, S16LE }, layout=(string)interleaved, rate=(int){ 16000, 22050, 24000, 32000, 44100, 48000 }, channels=(int)1; audio/x-raw, format=(string){ F32LE, S16LE }, layout=(string)interleaved, rate=(int){ 16000, 22050, 24000, 32000, 44100, 48000 }, channels=(int)2, channel-mask=(bitmask)0x0000000000000003</details>
</caps>
<caps>
<name>src</name>
<direction>source</direction>
<presence>always</presence>
<details>audio/mpeg, mpegversion=(int)1, layer=(int)2, rate=(int){ 16000, 22050, 24000, 32000, 44100, 48000 }, channels=(int)[ 1, 2 ]</details>
</caps>
</pads>
</element>
</elements>
</plugin>

View file

@ -40,12 +40,6 @@ else
SIDPLAY_DIR =
endif
if USE_TWOLAME
TWOLAME_DIR = twolame
else
TWOLAME_DIR =
endif
if USE_X264
X264_DIR=x264
else
@ -60,7 +54,6 @@ SUBDIRS = \
$(DVDREAD_DIR) \
$(MPEG2DEC_DIR) \
$(SIDPLAY_DIR) \
$(TWOLAME_DIR) \
$(X264_DIR)
DIST_SUBDIRS = \
@ -71,7 +64,6 @@ DIST_SUBDIRS = \
dvdread \
mpeg2dec \
sidplay \
twolame \
x264
include $(top_srcdir)/common/parallel-subdirs.mak

View file

@ -5,5 +5,4 @@ subdir('cdio')
subdir('dvdread')
subdir('mpeg2dec')
subdir('sidplay')
subdir('twolame')
subdir('x264')

View file

@ -1,11 +0,0 @@
plugin_LTLIBRARIES = libgsttwolame.la
libgsttwolame_la_SOURCES = gsttwolamemp2enc.c
libgsttwolame_la_CFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS) $(TWOLAME_CFLAGS)
libgsttwolame_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
-lgstaudio-@GST_API_VERSION@ -lgstpbutils-@GST_API_VERSION@ \
$(GST_LIBS) $(TWOLAME_LIBS)
libgsttwolame_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
noinst_HEADERS = gsttwolamemp2enc.h

View file

@ -1,893 +0,0 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2004> Wim Taymans <wim@fluendo.com>
* Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
* Copyright (C) <2008> Sebastian Dröge <sebastian.droege@collabora.co.uk>
*
* 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.
*/
/*
* Based on the lame element.
*/
/**
* SECTION:element-twolame
* @see_also: mad, lame
*
* This element encodes raw integer audio into an MPEG-1 layer 2 (MP2) stream.
*
* <refsect2>
* <title>Example pipelines</title>
* |[
* gst-launch-1.0 -v audiotestsrc wave=sine num-buffers=100 ! audioconvert ! twolame ! filesink location=sine.mp2
* ]| Encode a test sine signal to MP2.
* |[
* gst-launch-1.0 -v alsasrc ! audioconvert ! twolame bitrate=192 ! filesink location=alsasrc.mp2
* ]| Record from a sound card using ALSA and encode to MP2
* |[
* gst-launch-1.0 -v filesrc location=music.wav ! decodebin ! audioconvert ! audioresample ! twolame bitrate=192 ! id3v2mux ! filesink location=music.mp2
* ]| Transcode from a .wav file to MP2 (the id3v2mux element is optional)
* |[
* gst-launch-1.0 -v cdda://5 ! audioconvert ! twolame bitrate=192 ! filesink location=track5.mp2
* ]| Encode Audio CD track 5 to MP2
* </refsect2>
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "string.h"
#include "gsttwolamemp2enc.h"
#include "gst/gst-i18n-plugin.h"
GST_DEBUG_CATEGORY_STATIC (debug);
#define GST_CAT_DEFAULT debug
/* TwoLAME can do MPEG-1, MPEG-2 so it has 6 possible
* sample rates it supports */
static GstStaticPadTemplate gst_two_lame_sink_template =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) { " GST_AUDIO_NE (F32) ", " GST_AUDIO_NE (S16) " }, "
"layout = (string) interleaved, "
"rate = (int) { 16000, 22050, 24000, 32000, 44100, 48000 }, "
"channels = (int) 1; "
"audio/x-raw, "
"format = (string) { " GST_AUDIO_NE (F32) ", " GST_AUDIO_NE (S16) " }, "
"layout = (string) interleaved, "
"rate = (int) { 16000, 22050, 24000, 32000, 44100, 48000 }, "
"channels = (int) 2," "channel-mask = (bitmask) 0x3")
);
static GstStaticPadTemplate gst_two_lame_src_template =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/mpeg, "
"mpegversion = (int) 1, "
"layer = (int) 2, "
"rate = (int) { 16000, 22050, 24000, 32000, 44100, 48000 }, "
"channels = (int) [ 1, 2 ]")
);
static struct
{
gint mode;
gint psymodel;
gint bitrate;
gint padding;
gboolean energy_level_extension;
gint emphasis;
gboolean error_protection;
gboolean copyright;
gboolean original;
gboolean vbr;
gfloat vbr_level;
gfloat ath_level;
gint vbr_max_bitrate;
gboolean quick_mode;
gint quick_mode_count;
} gst_two_lame_default_settings;
/********** Define useful types for non-programmatic interfaces **********/
#define GST_TYPE_TWO_LAME_MODE (gst_two_lame_mode_get_type())
static GType
gst_two_lame_mode_get_type (void)
{
static GType two_lame_mode_type = 0;
static const GEnumValue two_lame_modes[] = {
{TWOLAME_AUTO_MODE, "Auto", "auto"},
{TWOLAME_STEREO, "Stereo", "stereo"},
{TWOLAME_JOINT_STEREO, "Joint Stereo", "joint"},
{TWOLAME_DUAL_CHANNEL, "Dual Channel", "dual"},
{TWOLAME_MONO, "Mono", "mono"},
{0, NULL, NULL}
};
if (!two_lame_mode_type) {
two_lame_mode_type =
g_enum_register_static ("GstTwoLameMode", two_lame_modes);
}
return two_lame_mode_type;
}
#define GST_TYPE_TWO_LAME_PADDING (gst_two_lame_padding_get_type())
static GType
gst_two_lame_padding_get_type (void)
{
static GType two_lame_padding_type = 0;
static const GEnumValue two_lame_padding[] = {
{TWOLAME_PAD_NO, "No Padding", "never"},
{TWOLAME_PAD_ALL, "Always Pad", "always"},
{0, NULL, NULL}
};
if (!two_lame_padding_type) {
two_lame_padding_type =
g_enum_register_static ("GstTwoLamePadding", two_lame_padding);
}
return two_lame_padding_type;
}
#define GST_TYPE_TWO_LAME_EMPHASIS (gst_two_lame_emphasis_get_type())
static GType
gst_two_lame_emphasis_get_type (void)
{
static GType two_lame_emphasis_type = 0;
static const GEnumValue two_lame_emphasis[] = {
{TWOLAME_EMPHASIS_N, "No emphasis", "none"},
{TWOLAME_EMPHASIS_5, "50/15 ms", "5"},
{TWOLAME_EMPHASIS_C, "CCIT J.17", "ccit"},
{0, NULL, NULL}
};
if (!two_lame_emphasis_type) {
two_lame_emphasis_type =
g_enum_register_static ("GstTwoLameEmphasis", two_lame_emphasis);
}
return two_lame_emphasis_type;
}
/********** Standard stuff for signals and arguments **********/
enum
{
ARG_0,
ARG_MODE,
ARG_PSYMODEL,
ARG_BITRATE,
ARG_PADDING,
ARG_ENERGY_LEVEL_EXTENSION,
ARG_EMPHASIS,
ARG_ERROR_PROTECTION,
ARG_COPYRIGHT,
ARG_ORIGINAL,
ARG_VBR,
ARG_VBR_LEVEL,
ARG_ATH_LEVEL,
ARG_VBR_MAX_BITRATE,
ARG_QUICK_MODE,
ARG_QUICK_MODE_COUNT
};
static gboolean gst_two_lame_start (GstAudioEncoder * enc);
static gboolean gst_two_lame_stop (GstAudioEncoder * enc);
static gboolean gst_two_lame_set_format (GstAudioEncoder * enc,
GstAudioInfo * info);
static GstFlowReturn gst_two_lame_handle_frame (GstAudioEncoder * enc,
GstBuffer * in_buf);
static void gst_two_lame_flush (GstAudioEncoder * enc);
static void gst_two_lame_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_two_lame_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static gboolean gst_two_lame_setup (GstTwoLame * twolame);
G_DEFINE_TYPE (GstTwoLame, gst_two_lame, GST_TYPE_AUDIO_ENCODER);
static void
gst_two_lame_release_memory (GstTwoLame * twolame)
{
if (twolame->glopts) {
twolame_close (&twolame->glopts);
twolame->glopts = NULL;
}
}
static void
gst_two_lame_finalize (GObject * obj)
{
gst_two_lame_release_memory (GST_TWO_LAME (obj));
G_OBJECT_CLASS (gst_two_lame_parent_class)->finalize (obj);
}
static void
gst_two_lame_class_init (GstTwoLameClass * klass)
{
GObjectClass *gobject_class;
GstAudioEncoderClass *gstbase_class;
gobject_class = (GObjectClass *) klass;
gstbase_class = (GstAudioEncoderClass *) klass;
gobject_class->set_property = gst_two_lame_set_property;
gobject_class->get_property = gst_two_lame_get_property;
gobject_class->finalize = gst_two_lame_finalize;
gstbase_class->start = GST_DEBUG_FUNCPTR (gst_two_lame_start);
gstbase_class->stop = GST_DEBUG_FUNCPTR (gst_two_lame_stop);
gstbase_class->set_format = GST_DEBUG_FUNCPTR (gst_two_lame_set_format);
gstbase_class->handle_frame = GST_DEBUG_FUNCPTR (gst_two_lame_handle_frame);
gstbase_class->flush = GST_DEBUG_FUNCPTR (gst_two_lame_flush);
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MODE,
g_param_spec_enum ("mode", "Mode", "Encoding mode",
GST_TYPE_TWO_LAME_MODE, gst_two_lame_default_settings.mode,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PSYMODEL,
g_param_spec_int ("psymodel", "Psychoacoustic Model",
"Psychoacoustic model used to encode the audio",
-1, 4, gst_two_lame_default_settings.psymodel,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BITRATE,
g_param_spec_int ("bitrate", "Bitrate (kb/s)",
"Bitrate in kbit/sec (8, 16, 24, 32, 40, 48, 56, 64, 80, 96, "
"112, 128, 144, 160, 192, 224, 256, 320, 384)",
8, 384, gst_two_lame_default_settings.bitrate,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_PADDING,
g_param_spec_enum ("padding", "Padding", "Padding type",
GST_TYPE_TWO_LAME_PADDING, gst_two_lame_default_settings.padding,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass),
ARG_ENERGY_LEVEL_EXTENSION,
g_param_spec_boolean ("energy-level-extension", "Energy Level Extension",
"Write peak PCM level to each frame",
gst_two_lame_default_settings.energy_level_extension,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_EMPHASIS,
g_param_spec_enum ("emphasis", "Emphasis",
"Pre-emphasis to apply to the decoded audio",
GST_TYPE_TWO_LAME_EMPHASIS, gst_two_lame_default_settings.emphasis,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ERROR_PROTECTION,
g_param_spec_boolean ("error-protection", "Error protection",
"Adds checksum to every frame",
gst_two_lame_default_settings.error_protection,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_COPYRIGHT,
g_param_spec_boolean ("copyright", "Copyright", "Mark as copyright",
gst_two_lame_default_settings.copyright,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ORIGINAL,
g_param_spec_boolean ("original", "Original", "Mark as original",
gst_two_lame_default_settings.original,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR,
g_param_spec_boolean ("vbr", "VBR", "Enable variable bitrate mode",
gst_two_lame_default_settings.vbr,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_LEVEL,
g_param_spec_float ("vbr-level", "VBR Level", "VBR Level",
-10.0, 10.0, gst_two_lame_default_settings.vbr_level,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_ATH_LEVEL,
g_param_spec_float ("ath-level", "ATH Level", "ATH Level in dB",
-G_MAXFLOAT, G_MAXFLOAT, gst_two_lame_default_settings.ath_level,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_VBR_MAX_BITRATE,
g_param_spec_int ("vbr-max-bitrate", "VBR max bitrate",
"Specify maximum VBR bitrate (0=off, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, "
"112, 128, 144, 160, 192, 224, 256, 320, 384)",
0, 384, gst_two_lame_default_settings.vbr_max_bitrate,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUICK_MODE,
g_param_spec_boolean ("quick-mode", "Quick mode",
"Calculate Psymodel every frames",
gst_two_lame_default_settings.quick_mode,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_QUICK_MODE_COUNT,
g_param_spec_int ("quick-mode-count", "Quick mode count",
"Calculate Psymodel every n frames",
0, G_MAXINT, gst_two_lame_default_settings.quick_mode_count,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
gst_element_class_add_static_pad_template (GST_ELEMENT_CLASS (klass),
&gst_two_lame_src_template);
gst_element_class_add_static_pad_template (GST_ELEMENT_CLASS (klass),
&gst_two_lame_sink_template);
gst_element_class_set_static_metadata (GST_ELEMENT_CLASS (klass),
"TwoLAME mp2 encoder", "Codec/Encoder/Audio",
"High-quality free MP2 encoder",
"Sebastian Dröge <sebastian.droege@collabora.co.uk>");
}
static gboolean
gst_two_lame_set_format (GstAudioEncoder * enc, GstAudioInfo * info)
{
GstTwoLame *twolame;
gint out_samplerate;
gint version;
GstCaps *othercaps;
twolame = GST_TWO_LAME (enc);
/* parameters already parsed for us */
twolame->samplerate = GST_AUDIO_INFO_RATE (info);
twolame->num_channels = GST_AUDIO_INFO_CHANNELS (info);
twolame->float_input = !GST_AUDIO_INFO_IS_INTEGER (info);
/* but we might be asked to reconfigure, so reset */
gst_two_lame_release_memory (twolame);
GST_DEBUG_OBJECT (twolame, "setting up twolame");
if (!gst_two_lame_setup (twolame))
goto setup_failed;
out_samplerate = twolame_get_out_samplerate (twolame->glopts);
if (out_samplerate == 0)
goto zero_output_rate;
if (out_samplerate != twolame->samplerate) {
GST_WARNING_OBJECT (twolame,
"output samplerate %d is different from incoming samplerate %d",
out_samplerate, twolame->samplerate);
}
version = twolame_get_version (twolame->glopts);
if (version == TWOLAME_MPEG2)
version = 2;
else
version = 1;
othercaps =
gst_caps_new_simple ("audio/mpeg",
"mpegversion", G_TYPE_INT, 1,
"mpegaudioversion", G_TYPE_INT, version,
"layer", G_TYPE_INT, 2,
"channels", G_TYPE_INT,
twolame->mode == TWOLAME_MONO ? 1 : twolame->num_channels, "rate",
G_TYPE_INT, out_samplerate, NULL);
/* and use these caps */
gst_audio_encoder_set_output_format (GST_AUDIO_ENCODER (twolame), othercaps);
gst_caps_unref (othercaps);
/* report needs to base class:
* hand one frame at a time, if we are pretty sure what a frame is */
if (out_samplerate == twolame->samplerate) {
gst_audio_encoder_set_frame_samples_min (enc, 1152);
gst_audio_encoder_set_frame_samples_max (enc, 1152);
gst_audio_encoder_set_frame_max (enc, 1);
}
return TRUE;
zero_output_rate:
{
GST_ELEMENT_ERROR (twolame, LIBRARY, SETTINGS, (NULL),
("TwoLAME decided on a zero sample rate"));
return FALSE;
}
setup_failed:
{
GST_ELEMENT_ERROR (twolame, LIBRARY, SETTINGS,
(_("Failed to configure TwoLAME encoder. Check your encoding parameters.")), (NULL));
return FALSE;
}
}
static void
gst_two_lame_init (GstTwoLame * twolame)
{
GST_DEBUG_OBJECT (twolame, "starting initialization");
GST_PAD_SET_ACCEPT_TEMPLATE (GST_AUDIO_ENCODER_SINK_PAD (twolame));
twolame->mode = gst_two_lame_default_settings.mode;
twolame->psymodel = gst_two_lame_default_settings.psymodel;
twolame->bitrate = gst_two_lame_default_settings.bitrate;
twolame->padding = gst_two_lame_default_settings.padding;
twolame->energy_level_extension =
gst_two_lame_default_settings.energy_level_extension;
twolame->emphasis = gst_two_lame_default_settings.emphasis;
twolame->error_protection = gst_two_lame_default_settings.error_protection;
twolame->copyright = gst_two_lame_default_settings.copyright;
twolame->original = gst_two_lame_default_settings.original;
twolame->vbr = gst_two_lame_default_settings.vbr;
twolame->vbr_level = gst_two_lame_default_settings.vbr_level;
twolame->ath_level = gst_two_lame_default_settings.ath_level;
twolame->vbr_max_bitrate = gst_two_lame_default_settings.vbr_max_bitrate;
twolame->quick_mode = gst_two_lame_default_settings.quick_mode;
twolame->quick_mode_count = gst_two_lame_default_settings.quick_mode_count;
GST_DEBUG_OBJECT (twolame, "done initializing");
}
static gboolean
gst_two_lame_start (GstAudioEncoder * enc)
{
GstTwoLame *twolame = GST_TWO_LAME (enc);
GST_DEBUG_OBJECT (twolame, "start");
return TRUE;
}
static gboolean
gst_two_lame_stop (GstAudioEncoder * enc)
{
GstTwoLame *twolame = GST_TWO_LAME (enc);
GST_DEBUG_OBJECT (twolame, "stop");
gst_two_lame_release_memory (twolame);
return TRUE;
}
/* <php-emulation-mode>three underscores for ___rate is really really really
* private as opposed to one underscore<php-emulation-mode> */
/* call this MACRO outside of the NULL state so that we have a higher chance
* of actually having a pipeline and bus to get the message through */
#define CHECK_AND_FIXUP_BITRATE(obj,param,rate) \
G_STMT_START { \
gint ___rate = rate; \
gint maxrate = 320; \
gint multiplier = 64; \
if (rate <= 64) { \
maxrate = 64; multiplier = 8; \
if ((rate % 8) != 0) ___rate = GST_ROUND_UP_8 (rate); \
} else if (rate <= 144) { \
maxrate = 144; multiplier = 16; \
if ((rate % 16) != 0) ___rate = GST_ROUND_UP_16 (rate); \
} else if (rate <= 256) { \
maxrate = 256; multiplier = 32; \
if ((rate % 32) != 0) ___rate = GST_ROUND_UP_32 (rate); \
} else if (rate <= 384) { \
maxrate = 384; multiplier = 64; \
if ((rate % 64) != 0) ___rate = GST_ROUND_UP_64 (rate); \
} \
if (___rate != rate) { \
GST_ELEMENT_WARNING (obj, LIBRARY, SETTINGS, \
(_("The requested bitrate %d kbit/s for property '%s' " \
"is not allowed. " \
"The bitrate was changed to %d kbit/s."), rate, \
param, ___rate), \
("A bitrate below %d should be a multiple of %d.", \
maxrate, multiplier)); \
rate = ___rate; \
} \
} G_STMT_END
static void
gst_two_lame_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstTwoLame *twolame = GST_TWO_LAME (object);
switch (prop_id) {
case ARG_MODE:
twolame->mode = g_value_get_enum (value);
break;
case ARG_PSYMODEL:
twolame->psymodel = g_value_get_int (value);
break;
case ARG_BITRATE:
twolame->bitrate = g_value_get_int (value);
break;
case ARG_PADDING:
twolame->padding = g_value_get_enum (value);
break;
case ARG_ENERGY_LEVEL_EXTENSION:
twolame->energy_level_extension = g_value_get_boolean (value);
break;
case ARG_EMPHASIS:
twolame->emphasis = g_value_get_enum (value);
break;
case ARG_ERROR_PROTECTION:
twolame->error_protection = g_value_get_boolean (value);
break;
case ARG_COPYRIGHT:
twolame->copyright = g_value_get_boolean (value);
break;
case ARG_ORIGINAL:
twolame->original = g_value_get_boolean (value);
break;
case ARG_VBR:
twolame->vbr = g_value_get_boolean (value);
break;
case ARG_VBR_LEVEL:
twolame->vbr_level = g_value_get_float (value);
break;
case ARG_ATH_LEVEL:
twolame->ath_level = g_value_get_float (value);
break;
case ARG_VBR_MAX_BITRATE:
twolame->vbr_max_bitrate = g_value_get_int (value);
break;
case ARG_QUICK_MODE:
twolame->quick_mode = g_value_get_boolean (value);
break;
case ARG_QUICK_MODE_COUNT:
twolame->quick_mode_count = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_two_lame_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
{
GstTwoLame *twolame = GST_TWO_LAME (object);
switch (prop_id) {
case ARG_MODE:
g_value_set_enum (value, twolame->mode);
break;
case ARG_PSYMODEL:
g_value_set_int (value, twolame->psymodel);
break;
case ARG_BITRATE:
g_value_set_int (value, twolame->bitrate);
break;
case ARG_PADDING:
g_value_set_enum (value, twolame->padding);
break;
case ARG_ENERGY_LEVEL_EXTENSION:
g_value_set_boolean (value, twolame->energy_level_extension);
break;
case ARG_EMPHASIS:
g_value_set_enum (value, twolame->emphasis);
break;
case ARG_ERROR_PROTECTION:
g_value_set_boolean (value, twolame->error_protection);
break;
case ARG_COPYRIGHT:
g_value_set_boolean (value, twolame->copyright);
break;
case ARG_ORIGINAL:
g_value_set_boolean (value, twolame->original);
break;
case ARG_VBR:
g_value_set_boolean (value, twolame->vbr);
break;
case ARG_VBR_LEVEL:
g_value_set_float (value, twolame->vbr_level);
break;
case ARG_ATH_LEVEL:
g_value_set_float (value, twolame->ath_level);
break;
case ARG_VBR_MAX_BITRATE:
g_value_set_int (value, twolame->vbr_max_bitrate);
break;
case ARG_QUICK_MODE:
g_value_set_boolean (value, twolame->quick_mode);
break;
case ARG_QUICK_MODE_COUNT:
g_value_set_int (value, twolame->quick_mode_count);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static GstFlowReturn
gst_two_lame_flush_full (GstTwoLame * lame, gboolean push)
{
GstBuffer *buf;
GstMapInfo map;
gint size;
GstFlowReturn result = GST_FLOW_OK;
if (!lame->glopts)
return GST_FLOW_OK;
buf = gst_buffer_new_and_alloc (16384);
gst_buffer_map (buf, &map, GST_MAP_WRITE);
size = twolame_encode_flush (lame->glopts, map.data, 16384);
gst_buffer_unmap (buf, &map);
if (size > 0 && push) {
gst_buffer_set_size (buf, size);
GST_DEBUG_OBJECT (lame, "pushing final packet of %u bytes", size);
result = gst_audio_encoder_finish_frame (GST_AUDIO_ENCODER (lame), buf, -1);
} else {
GST_DEBUG_OBJECT (lame, "no final packet (size=%d, push=%d)", size, push);
gst_buffer_unref (buf);
result = GST_FLOW_OK;
}
return result;
}
static void
gst_two_lame_flush (GstAudioEncoder * enc)
{
gst_two_lame_flush_full (GST_TWO_LAME (enc), FALSE);
}
static GstFlowReturn
gst_two_lame_handle_frame (GstAudioEncoder * enc, GstBuffer * buf)
{
GstTwoLame *twolame;
gint mp3_buffer_size, mp3_size;
GstBuffer *mp3_buf;
GstFlowReturn result;
gint num_samples;
GstMapInfo map, mp3_map;
twolame = GST_TWO_LAME (enc);
/* squeeze remaining and push */
if (G_UNLIKELY (buf == NULL))
return gst_two_lame_flush_full (twolame, TRUE);
gst_buffer_map (buf, &map, GST_MAP_READ);
if (twolame->float_input)
num_samples = map.size / 4;
else
num_samples = map.size / 2;
/* allocate space for output */
mp3_buffer_size = 1.25 * num_samples + 16384;
mp3_buf = gst_buffer_new_and_alloc (mp3_buffer_size);
gst_buffer_map (mp3_buf, &mp3_map, GST_MAP_WRITE);
if (twolame->num_channels == 1) {
if (twolame->float_input)
mp3_size = twolame_encode_buffer_float32 (twolame->glopts,
(float *) map.data,
(float *) map.data, num_samples, mp3_map.data, mp3_buffer_size);
else
mp3_size = twolame_encode_buffer (twolame->glopts,
(short int *) map.data,
(short int *) map.data, num_samples, mp3_map.data, mp3_buffer_size);
} else {
if (twolame->float_input)
mp3_size = twolame_encode_buffer_float32_interleaved (twolame->glopts,
(float *) map.data,
num_samples / twolame->num_channels, mp3_map.data, mp3_buffer_size);
else
mp3_size = twolame_encode_buffer_interleaved (twolame->glopts,
(short int *) map.data,
num_samples / twolame->num_channels, mp3_map.data, mp3_buffer_size);
}
GST_LOG_OBJECT (twolame, "encoded %" G_GSIZE_FORMAT " bytes of audio "
"to %d bytes of mp3", map.size, mp3_size);
gst_buffer_unmap (buf, &map);
gst_buffer_unmap (mp3_buf, &mp3_map);
if (mp3_size > 0) {
gst_buffer_set_size (mp3_buf, mp3_size);
result = gst_audio_encoder_finish_frame (enc, mp3_buf, -1);
} else {
if (mp3_size < 0) {
/* eat error ? */
g_warning ("error %d", mp3_size);
}
gst_buffer_unref (mp3_buf);
result = GST_FLOW_OK;
}
return result;
}
/* set up the encoder state */
static gboolean
gst_two_lame_setup (GstTwoLame * twolame)
{
#define CHECK_ERROR(command) G_STMT_START {\
if ((command) < 0) { \
GST_ERROR_OBJECT (twolame, "setup failed: " G_STRINGIFY (command)); \
return FALSE; \
} \
}G_STMT_END
int retval;
GstCaps *allowed_caps;
GST_DEBUG_OBJECT (twolame, "starting setup");
/* check if we're already setup; if we are, we might want to check
* if this initialization is compatible with the previous one */
/* FIXME: do this */
if (twolame->setup) {
GST_WARNING_OBJECT (twolame, "already setup");
twolame->setup = FALSE;
}
twolame->glopts = twolame_init ();
if (twolame->glopts == NULL)
return FALSE;
/* copy the parameters over */
twolame_set_in_samplerate (twolame->glopts, twolame->samplerate);
/* let twolame choose default samplerate unless outgoing sample rate is fixed */
allowed_caps = gst_pad_get_allowed_caps (GST_AUDIO_ENCODER_SRC_PAD (twolame));
if (allowed_caps != NULL) {
GstStructure *structure;
gint samplerate;
structure = gst_caps_get_structure (allowed_caps, 0);
if (gst_structure_get_int (structure, "rate", &samplerate)) {
GST_DEBUG_OBJECT (twolame,
"Setting sample rate to %d as fixed in src caps", samplerate);
twolame_set_out_samplerate (twolame->glopts, samplerate);
} else {
GST_DEBUG_OBJECT (twolame, "Letting twolame choose sample rate");
twolame_set_out_samplerate (twolame->glopts, 0);
}
gst_caps_unref (allowed_caps);
allowed_caps = NULL;
} else {
GST_DEBUG_OBJECT (twolame,
"No peer yet, letting twolame choose sample rate");
twolame_set_out_samplerate (twolame->glopts, 0);
}
/* force mono encoding if we only have one channel */
if (twolame->num_channels == 1)
twolame->mode = 3;
/* Fix bitrates and MPEG version */
CHECK_ERROR (twolame_set_num_channels (twolame->glopts,
twolame->num_channels));
CHECK_ERROR (twolame_set_mode (twolame->glopts, twolame->mode));
CHECK_ERROR (twolame_set_psymodel (twolame->glopts, twolame->psymodel));
CHECK_AND_FIXUP_BITRATE (twolame, "bitrate", twolame->bitrate);
CHECK_ERROR (twolame_set_bitrate (twolame->glopts, twolame->bitrate));
CHECK_ERROR (twolame_set_padding (twolame->glopts, twolame->padding));
CHECK_ERROR (twolame_set_energy_levels (twolame->glopts,
twolame->energy_level_extension));
CHECK_ERROR (twolame_set_emphasis (twolame->glopts, twolame->emphasis));
CHECK_ERROR (twolame_set_error_protection (twolame->glopts,
twolame->error_protection));
CHECK_ERROR (twolame_set_copyright (twolame->glopts, twolame->copyright));
CHECK_ERROR (twolame_set_original (twolame->glopts, twolame->original));
CHECK_ERROR (twolame_set_VBR (twolame->glopts, twolame->vbr));
CHECK_ERROR (twolame_set_VBR_level (twolame->glopts, twolame->vbr_level));
CHECK_ERROR (twolame_set_ATH_level (twolame->glopts, twolame->ath_level));
CHECK_AND_FIXUP_BITRATE (twolame, "vbr-max-bitrate",
twolame->vbr_max_bitrate);
CHECK_ERROR (twolame_set_VBR_max_bitrate_kbps (twolame->glopts,
twolame->vbr_max_bitrate));
CHECK_ERROR (twolame_set_quick_mode (twolame->glopts, twolame->quick_mode));
CHECK_ERROR (twolame_set_quick_count (twolame->glopts,
twolame->quick_mode_count));
/* initialize the twolame encoder */
if ((retval = twolame_init_params (twolame->glopts)) >= 0) {
twolame->setup = TRUE;
/* FIXME: it would be nice to print out the mode here */
GST_INFO ("twolame encoder setup (%d kbit/s, %d Hz, %d channels)",
twolame->bitrate, twolame->samplerate, twolame->num_channels);
} else {
GST_ERROR_OBJECT (twolame, "twolame_init_params returned %d", retval);
}
GST_DEBUG_OBJECT (twolame, "done with setup");
return twolame->setup;
#undef CHECK_ERROR
}
static gboolean
gst_two_lame_get_default_settings (void)
{
twolame_options *glopts = NULL;
glopts = twolame_init ();
if (glopts == NULL) {
GST_ERROR ("Couldn't initialize TwoLAME");
return FALSE;
}
twolame_set_num_channels (glopts, 2);
twolame_set_in_samplerate (glopts, 44100);
if (twolame_init_params (glopts) != 0) {
GST_ERROR ("Couldn't set default parameters");
return FALSE;
}
gst_two_lame_default_settings.mode = TWOLAME_JOINT_STEREO; /* twolame_get_mode (glopts); */
gst_two_lame_default_settings.psymodel = twolame_get_psymodel (glopts);
gst_two_lame_default_settings.bitrate = twolame_get_bitrate (glopts);
gst_two_lame_default_settings.padding = twolame_get_padding (glopts);
gst_two_lame_default_settings.energy_level_extension =
twolame_get_energy_levels (glopts);
gst_two_lame_default_settings.emphasis = twolame_get_emphasis (glopts);
gst_two_lame_default_settings.error_protection =
twolame_get_error_protection (glopts);
gst_two_lame_default_settings.copyright = twolame_get_copyright (glopts);
gst_two_lame_default_settings.original = twolame_get_original (glopts);
gst_two_lame_default_settings.vbr = twolame_get_VBR (glopts);
gst_two_lame_default_settings.vbr_level = twolame_get_VBR_level (glopts);
gst_two_lame_default_settings.ath_level = twolame_get_ATH_level (glopts);
gst_two_lame_default_settings.vbr_max_bitrate =
twolame_get_VBR_max_bitrate_kbps (glopts);
gst_two_lame_default_settings.quick_mode = twolame_get_quick_mode (glopts);
gst_two_lame_default_settings.quick_mode_count =
twolame_get_quick_count (glopts);
twolame_close (&glopts);
return TRUE;
}
static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (debug, "twolame", 0, "twolame mp2 encoder");
if (!gst_two_lame_get_default_settings ())
return FALSE;
#ifdef ENABLE_NLS
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
LOCALEDIR);
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
#endif /* ENABLE_NLS */
if (!gst_element_register (plugin, "twolamemp2enc", GST_RANK_PRIMARY,
GST_TYPE_TWO_LAME))
return FALSE;
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
twolame,
"Encode MP2s with TwoLAME",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);

View file

@ -1,88 +0,0 @@
/* GStreamer
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
* Copyright (C) <2008> Sebastian Dröge <sebastian.droege@collabora.co.uk>
*
* 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_TWO_LAME_H__
#define __GST_TWO_LAME_H__
#include <gst/gst.h>
#include <gst/audio/gstaudioencoder.h>
G_BEGIN_DECLS
#include <twolame.h>
#define GST_TYPE_TWO_LAME \
(gst_two_lame_get_type())
#define GST_TWO_LAME(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TWO_LAME,GstTwoLame))
#define GST_TWO_LAME_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TWO_LAME,GstTwoLameClass))
#define GST_IS_TWO_LAME(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TWO_LAME))
#define GST_IS_TWO_LAME_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TWO_LAME))
typedef struct _GstTwoLame GstTwoLame;
typedef struct _GstTwoLameClass GstTwoLameClass;
/**
* GstTwoLame:
*
* Opaque data structure.
*/
struct _GstTwoLame {
GstAudioEncoder element;
gint samplerate;
gint num_channels;
gboolean float_input;
gboolean setup;
gint mode;
gint psymodel;
gint bitrate;
gint padding;
gboolean energy_level_extension;
gint emphasis;
gboolean error_protection;
gboolean copyright;
gboolean original;
gboolean vbr;
gfloat vbr_level;
gfloat ath_level;
gint vbr_max_bitrate;
gboolean quick_mode;
gint quick_mode_count;
twolame_options *glopts;
};
struct _GstTwoLameClass {
GstAudioEncoderClass parent_class;
};
GType gst_two_lame_get_type(void);
G_END_DECLS
#endif /* __GST_TWO_LAME_H__ */

View file

@ -1,12 +0,0 @@
twolame_dep = dependency('twolame', version : '>= 0.3.10', required : false)
if twolame_dep.found()
twolame = library('gsttwolame',
['gsttwolamemp2enc.c'],
c_args : ugly_args,
include_directories : [configinc, libsinc],
dependencies : [gstaudio_dep, twolame_dep],
install : true,
install_dir : plugins_install_dir,
)
endif

View file

@ -1,4 +1,3 @@
ext/cdio/gstcdiocddasrc.c
ext/dvdread/dvdreadsrc.c
ext/twolame/gsttwolamemp2enc.c
gst/asfdemux/gstasfdemux.c