2003-11-21 21:20:42 +00:00
|
|
|
/* GStreamer FAAD (Free AAC Decoder) plugin
|
|
|
|
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
|
2003-11-21 21:20:42 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-11-03 20:38:00 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2003-11-21 21:20:42 +00:00
|
|
|
*/
|
|
|
|
|
2010-02-11 20:57:49 +00:00
|
|
|
/**
|
|
|
|
* SECTION:element-faad
|
2017-03-08 18:01:13 +00:00
|
|
|
* @title: faad
|
2021-06-14 13:07:05 +00:00
|
|
|
* @see_also: faac
|
2010-02-11 20:57:49 +00:00
|
|
|
*
|
|
|
|
* faad decodes AAC (MPEG-4 part 3) stream.
|
|
|
|
*
|
2017-03-08 18:01:13 +00:00
|
|
|
* ## Example launch lines
|
2010-02-16 07:49:05 +00:00
|
|
|
* |[
|
2015-12-14 02:09:46 +00:00
|
|
|
* gst-launch-1.0 filesrc location=example.mp4 ! qtdemux ! faad ! audioconvert ! audioresample ! autoaudiosink
|
2010-02-16 07:49:05 +00:00
|
|
|
* ]| Play aac from mp4 file.
|
|
|
|
* |[
|
2015-12-14 02:09:46 +00:00
|
|
|
* gst-launch-1.0 filesrc location=example.adts ! faad ! audioconvert ! audioresample ! autoaudiosink
|
2010-02-16 07:49:05 +00:00
|
|
|
* ]| Play standalone aac bitstream.
|
2017-03-08 18:01:13 +00:00
|
|
|
*
|
2010-02-11 20:57:49 +00:00
|
|
|
*/
|
|
|
|
|
2003-11-21 21:20:42 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
2005-10-20 15:08:14 +00:00
|
|
|
#include <gst/audio/audio.h>
|
2005-11-11 18:17:22 +00:00
|
|
|
|
2003-11-21 21:20:42 +00:00
|
|
|
#include "gstfaad.h"
|
2009-03-06 11:42:50 +00:00
|
|
|
|
2005-08-10 09:33:58 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (faad_debug);
|
|
|
|
#define GST_CAT_DEFAULT faad_debug
|
|
|
|
|
2004-11-07 18:30:06 +00:00
|
|
|
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2012-02-02 11:31:32 +00:00
|
|
|
GST_STATIC_CAPS ("audio/mpeg, " "mpegversion = (int) 2; "
|
|
|
|
"audio/mpeg, mpegversion = (int) 4, stream-format = (string) { raw, adts }")
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
|
|
|
|
2011-09-27 11:22:31 +00:00
|
|
|
#define STATIC_RAW_CAPS(format) \
|
|
|
|
"audio/x-raw, " \
|
|
|
|
"format = (string) "GST_AUDIO_NE(format)", " \
|
2012-01-05 09:23:07 +00:00
|
|
|
"layout = (string) interleaved, " \
|
Surround sound support.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
(gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init):
* ext/alsa/gstalsa.c: (gst_alsa_get_caps):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_channels),
(gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init):
* ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst),
(gst_faad_chanpos_to_gst), (gst_faad_sinkconnect),
(gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain),
(gst_faad_change_state), (plugin_init):
* ext/faad/gstfaad.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
* gst-libs/gst/audio/Makefile.am:
* gst-libs/gst/audio/audio.c: (plugin_init):
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions),
(gst_audio_get_channel_positions),
(gst_audio_set_channel_positions),
(gst_audio_set_structure_channel_positions_list),
(add_list_to_struct), (gst_audio_set_caps_channel_positions_list),
(gst_audio_fixate_channel_positions):
* gst-libs/gst/audio/multichannel.h:
* gst-libs/gst/audio/testchannels.c: (main):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_getcaps),
(gst_audio_convert_parse_caps), (gst_audio_convert_link),
(gst_audio_convert_fixate), (gst_audio_convert_channels):
* gst/audioconvert/plugin.c: (plugin_init):
Surround sound support.
2004-11-25 20:36:29 +00:00
|
|
|
"rate = (int) [ 8000, 96000 ], " \
|
|
|
|
"channels = (int) [ 1, 8 ]"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* All except 16-bit integer are disabled until someone fixes FAAD.
|
|
|
|
* FAAD allocates approximately 8*1024*2 bytes bytes, which is enough
|
|
|
|
* for 1 frame (1024 samples) of 6 channel (5.1) 16-bit integer 16bpp
|
|
|
|
* audio, but not for any other. You'll get random segfaults, crashes
|
|
|
|
* and even valgrind goes crazy.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define STATIC_CAPS \
|
2011-09-27 11:22:31 +00:00
|
|
|
STATIC_RAW_CAPS (S16)
|
Surround sound support.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
(gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init):
* ext/alsa/gstalsa.c: (gst_alsa_get_caps):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_channels),
(gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init):
* ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst),
(gst_faad_chanpos_to_gst), (gst_faad_sinkconnect),
(gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain),
(gst_faad_change_state), (plugin_init):
* ext/faad/gstfaad.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
* gst-libs/gst/audio/Makefile.am:
* gst-libs/gst/audio/audio.c: (plugin_init):
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions),
(gst_audio_get_channel_positions),
(gst_audio_set_channel_positions),
(gst_audio_set_structure_channel_positions_list),
(add_list_to_struct), (gst_audio_set_caps_channel_positions_list),
(gst_audio_fixate_channel_positions):
* gst-libs/gst/audio/multichannel.h:
* gst-libs/gst/audio/testchannels.c: (main):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_getcaps),
(gst_audio_convert_parse_caps), (gst_audio_convert_link),
(gst_audio_convert_fixate), (gst_audio_convert_channels):
* gst/audioconvert/plugin.c: (plugin_init):
Surround sound support.
2004-11-25 20:36:29 +00:00
|
|
|
#if 0
|
2005-01-06 10:34:40 +00:00
|
|
|
#define NOTUSED "; " \
|
2011-09-27 11:22:31 +00:00
|
|
|
STATIC_RAW_CAPS (S24) \
|
2005-01-06 10:34:40 +00:00
|
|
|
"; " \
|
2011-09-27 11:22:31 +00:00
|
|
|
STATIC_RAW_CAPS (S32) \
|
2005-01-06 10:34:40 +00:00
|
|
|
"; " \
|
2011-09-27 11:22:31 +00:00
|
|
|
STATIC_RAW_CAPS (F32) \
|
2005-01-06 10:34:40 +00:00
|
|
|
"; " \
|
2011-09-27 11:22:31 +00:00
|
|
|
STATIC_RAW_CAPS (F64)
|
Surround sound support.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
(gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init):
* ext/alsa/gstalsa.c: (gst_alsa_get_caps):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_channels),
(gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init):
* ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst),
(gst_faad_chanpos_to_gst), (gst_faad_sinkconnect),
(gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain),
(gst_faad_change_state), (plugin_init):
* ext/faad/gstfaad.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
* gst-libs/gst/audio/Makefile.am:
* gst-libs/gst/audio/audio.c: (plugin_init):
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions),
(gst_audio_get_channel_positions),
(gst_audio_set_channel_positions),
(gst_audio_set_structure_channel_positions_list),
(add_list_to_struct), (gst_audio_set_caps_channel_positions_list),
(gst_audio_fixate_channel_positions):
* gst-libs/gst/audio/multichannel.h:
* gst-libs/gst/audio/testchannels.c: (main):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_getcaps),
(gst_audio_convert_parse_caps), (gst_audio_convert_link),
(gst_audio_convert_fixate), (gst_audio_convert_channels):
* gst/audioconvert/plugin.c: (plugin_init):
Surround sound support.
2004-11-25 20:36:29 +00:00
|
|
|
#endif
|
2005-08-08 19:20:02 +00:00
|
|
|
|
2005-01-06 10:34:40 +00:00
|
|
|
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
Surround sound support.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
(gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init):
* ext/alsa/gstalsa.c: (gst_alsa_get_caps):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_channels),
(gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init):
* ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst),
(gst_faad_chanpos_to_gst), (gst_faad_sinkconnect),
(gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain),
(gst_faad_change_state), (plugin_init):
* ext/faad/gstfaad.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
* gst-libs/gst/audio/Makefile.am:
* gst-libs/gst/audio/audio.c: (plugin_init):
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions),
(gst_audio_get_channel_positions),
(gst_audio_set_channel_positions),
(gst_audio_set_structure_channel_positions_list),
(add_list_to_struct), (gst_audio_set_caps_channel_positions_list),
(gst_audio_fixate_channel_positions):
* gst-libs/gst/audio/multichannel.h:
* gst-libs/gst/audio/testchannels.c: (main):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_getcaps),
(gst_audio_convert_parse_caps), (gst_audio_convert_link),
(gst_audio_convert_fixate), (gst_audio_convert_channels):
* gst/audioconvert/plugin.c: (plugin_init):
Surround sound support.
2004-11-25 20:36:29 +00:00
|
|
|
GST_STATIC_CAPS (STATIC_CAPS)
|
2004-03-14 22:34:33 +00:00
|
|
|
);
|
|
|
|
|
2010-02-09 22:25:13 +00:00
|
|
|
static void gst_faad_reset (GstFaad * faad);
|
2011-09-22 07:49:21 +00:00
|
|
|
|
|
|
|
static gboolean gst_faad_start (GstAudioDecoder * dec);
|
|
|
|
static gboolean gst_faad_stop (GstAudioDecoder * dec);
|
|
|
|
static gboolean gst_faad_set_format (GstAudioDecoder * dec, GstCaps * caps);
|
2018-04-22 17:27:37 +00:00
|
|
|
static GstFlowReturn gst_faad_parse (GstAudioDecoder * dec,
|
|
|
|
GstAdapter * adapter, gint * offset, gint * length);
|
2011-09-22 07:49:21 +00:00
|
|
|
static GstFlowReturn gst_faad_handle_frame (GstAudioDecoder * dec,
|
|
|
|
GstBuffer * buffer);
|
|
|
|
static void gst_faad_flush (GstAudioDecoder * dec, gboolean hard);
|
|
|
|
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
static gboolean gst_faad_open_decoder (GstFaad * faad);
|
|
|
|
static void gst_faad_close_decoder (GstFaad * faad);
|
2003-11-21 21:20:42 +00:00
|
|
|
|
2011-09-27 11:22:31 +00:00
|
|
|
#define gst_faad_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE (GstFaad, gst_faad, GST_TYPE_AUDIO_DECODER);
|
2021-02-17 14:59:49 +00:00
|
|
|
GST_ELEMENT_REGISTER_DEFINE (faad, "faad", GST_RANK_SECONDARY, GST_TYPE_FAAD);
|
2003-11-21 21:20:42 +00:00
|
|
|
|
|
|
|
static void
|
2011-09-27 11:22:31 +00:00
|
|
|
gst_faad_class_init (GstFaadClass * klass)
|
2003-11-21 21:20:42 +00:00
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
2011-09-27 11:22:31 +00:00
|
|
|
GstAudioDecoderClass *base_class = GST_AUDIO_DECODER_CLASS (klass);
|
2003-11-21 21:20:42 +00:00
|
|
|
|
2016-03-04 06:50:26 +00:00
|
|
|
gst_element_class_add_static_pad_template (element_class, &src_template);
|
|
|
|
gst_element_class_add_static_pad_template (element_class, &sink_template);
|
2003-11-21 21:20:42 +00:00
|
|
|
|
2012-10-17 16:34:26 +00:00
|
|
|
gst_element_class_set_static_metadata (element_class, "AAC audio decoder",
|
2010-03-18 16:30:26 +00:00
|
|
|
"Codec/Decoder/Audio",
|
|
|
|
"Free MPEG-2/4 AAC decoder",
|
|
|
|
"Ronald Bultje <rbultje@ronald.bitfreak.net>");
|
2005-10-20 15:08:14 +00:00
|
|
|
|
2011-09-22 07:49:21 +00:00
|
|
|
base_class->start = GST_DEBUG_FUNCPTR (gst_faad_start);
|
|
|
|
base_class->stop = GST_DEBUG_FUNCPTR (gst_faad_stop);
|
|
|
|
base_class->set_format = GST_DEBUG_FUNCPTR (gst_faad_set_format);
|
|
|
|
base_class->parse = GST_DEBUG_FUNCPTR (gst_faad_parse);
|
|
|
|
base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_faad_handle_frame);
|
|
|
|
base_class->flush = GST_DEBUG_FUNCPTR (gst_faad_flush);
|
2011-09-27 11:22:31 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (faad_debug, "faad", 0, "AAC decoding");
|
2003-11-21 21:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-09-27 11:22:31 +00:00
|
|
|
gst_faad_init (GstFaad * faad)
|
2003-11-21 21:20:42 +00:00
|
|
|
{
|
2015-08-15 15:58:40 +00:00
|
|
|
gst_audio_decoder_set_use_default_pad_acceptcaps (GST_AUDIO_DECODER_CAST
|
|
|
|
(faad), TRUE);
|
|
|
|
GST_PAD_SET_ACCEPT_TEMPLATE (GST_AUDIO_DECODER_SINK_PAD (faad));
|
2010-02-09 22:25:13 +00:00
|
|
|
gst_faad_reset (faad);
|
|
|
|
}
|
|
|
|
|
2010-02-10 22:14:21 +00:00
|
|
|
static void
|
|
|
|
gst_faad_reset_stream_state (GstFaad * faad)
|
|
|
|
{
|
|
|
|
if (faad->handle)
|
|
|
|
faacDecPostSeekReset (faad->handle, 0);
|
|
|
|
}
|
|
|
|
|
2010-02-09 22:25:13 +00:00
|
|
|
static void
|
|
|
|
gst_faad_reset (GstFaad * faad)
|
|
|
|
{
|
|
|
|
faad->samplerate = -1;
|
|
|
|
faad->channels = -1;
|
|
|
|
faad->init = FALSE;
|
|
|
|
faad->packetised = FALSE;
|
|
|
|
g_free (faad->channel_positions);
|
|
|
|
faad->channel_positions = NULL;
|
2010-10-12 16:17:27 +00:00
|
|
|
faad->last_header = 0;
|
2010-02-10 22:14:21 +00:00
|
|
|
|
|
|
|
gst_faad_reset_stream_state (faad);
|
2006-03-04 20:04:11 +00:00
|
|
|
}
|
|
|
|
|
2011-09-22 07:49:21 +00:00
|
|
|
static gboolean
|
|
|
|
gst_faad_start (GstAudioDecoder * dec)
|
2010-02-10 20:12:07 +00:00
|
|
|
{
|
2011-09-22 07:49:21 +00:00
|
|
|
GstFaad *faad = GST_FAAD (dec);
|
2010-02-10 20:12:07 +00:00
|
|
|
|
2011-09-22 07:49:21 +00:00
|
|
|
GST_DEBUG_OBJECT (dec, "start");
|
|
|
|
gst_faad_reset (faad);
|
2010-02-10 20:12:07 +00:00
|
|
|
|
2011-09-22 07:49:21 +00:00
|
|
|
/* call upon legacy upstream byte support (e.g. seeking) */
|
2012-03-30 09:53:41 +00:00
|
|
|
gst_audio_decoder_set_estimate_rate (dec, TRUE);
|
2011-09-22 07:49:21 +00:00
|
|
|
/* never mind a few errors */
|
|
|
|
gst_audio_decoder_set_max_errors (dec, 10);
|
|
|
|
|
|
|
|
return TRUE;
|
2010-02-10 20:12:07 +00:00
|
|
|
}
|
|
|
|
|
2011-09-22 07:49:21 +00:00
|
|
|
static gboolean
|
|
|
|
gst_faad_stop (GstAudioDecoder * dec)
|
2006-03-04 20:04:11 +00:00
|
|
|
{
|
2011-09-22 07:49:21 +00:00
|
|
|
GstFaad *faad = GST_FAAD (dec);
|
2006-03-04 20:04:11 +00:00
|
|
|
|
2011-09-22 07:49:21 +00:00
|
|
|
GST_DEBUG_OBJECT (dec, "stop");
|
|
|
|
gst_faad_reset (faad);
|
|
|
|
gst_faad_close_decoder (faad);
|
2006-03-04 20:04:11 +00:00
|
|
|
|
2011-09-22 07:49:21 +00:00
|
|
|
return TRUE;
|
2003-11-21 21:20:42 +00:00
|
|
|
}
|
|
|
|
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
static gint
|
|
|
|
aac_rate_idx (gint rate)
|
|
|
|
{
|
|
|
|
if (92017 <= rate)
|
|
|
|
return 0;
|
|
|
|
else if (75132 <= rate)
|
|
|
|
return 1;
|
|
|
|
else if (55426 <= rate)
|
|
|
|
return 2;
|
|
|
|
else if (46009 <= rate)
|
|
|
|
return 3;
|
|
|
|
else if (37566 <= rate)
|
|
|
|
return 4;
|
|
|
|
else if (27713 <= rate)
|
|
|
|
return 5;
|
|
|
|
else if (23004 <= rate)
|
|
|
|
return 6;
|
|
|
|
else if (18783 <= rate)
|
|
|
|
return 7;
|
|
|
|
else if (13856 <= rate)
|
|
|
|
return 8;
|
|
|
|
else if (11502 <= rate)
|
|
|
|
return 9;
|
|
|
|
else if (9391 <= rate)
|
|
|
|
return 10;
|
|
|
|
else
|
|
|
|
return 11;
|
|
|
|
}
|
|
|
|
|
2005-07-19 20:51:15 +00:00
|
|
|
static gboolean
|
2011-09-22 07:49:21 +00:00
|
|
|
gst_faad_set_format (GstAudioDecoder * dec, GstCaps * caps)
|
2005-07-19 20:51:15 +00:00
|
|
|
{
|
2011-09-22 07:49:21 +00:00
|
|
|
GstFaad *faad = GST_FAAD (dec);
|
2005-08-08 19:20:02 +00:00
|
|
|
GstStructure *str = gst_caps_get_structure (caps, 0);
|
|
|
|
GstBuffer *buf;
|
|
|
|
const GValue *value;
|
2012-01-25 17:49:58 +00:00
|
|
|
GstMapInfo map;
|
2011-09-27 11:22:31 +00:00
|
|
|
guint8 *cdata;
|
|
|
|
gsize csize;
|
2005-07-19 20:51:15 +00:00
|
|
|
|
2010-10-14 09:24:42 +00:00
|
|
|
/* clean up current decoder, rather than trying to reconfigure */
|
|
|
|
gst_faad_close_decoder (faad);
|
|
|
|
|
2005-08-08 19:20:02 +00:00
|
|
|
/* Assume raw stream */
|
|
|
|
faad->packetised = FALSE;
|
2005-07-19 20:51:15 +00:00
|
|
|
|
2005-08-08 19:20:02 +00:00
|
|
|
if ((value = gst_structure_get_value (str, "codec_data"))) {
|
2009-03-06 11:42:50 +00:00
|
|
|
unsigned long samplerate;
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
guint8 channels;
|
2005-08-08 19:20:02 +00:00
|
|
|
|
|
|
|
/* We have codec data, means packetised stream */
|
|
|
|
faad->packetised = TRUE;
|
2006-10-06 15:49:39 +00:00
|
|
|
|
2011-09-22 07:49:21 +00:00
|
|
|
buf = gst_value_get_buffer (value);
|
2010-02-16 16:49:39 +00:00
|
|
|
g_return_val_if_fail (buf != NULL, FALSE);
|
|
|
|
|
2012-01-25 17:49:58 +00:00
|
|
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
|
|
|
cdata = map.data;
|
|
|
|
csize = map.size;
|
2006-10-06 15:49:39 +00:00
|
|
|
|
|
|
|
if (csize < 2)
|
|
|
|
goto wrong_length;
|
2005-07-19 20:51:15 +00:00
|
|
|
|
2010-02-10 18:14:19 +00:00
|
|
|
GST_DEBUG_OBJECT (faad,
|
|
|
|
"codec_data: object_type=%d, sample_rate=%d, channels=%d",
|
2009-01-23 14:00:10 +00:00
|
|
|
((cdata[0] & 0xf8) >> 3),
|
|
|
|
(((cdata[0] & 0x07) << 1) | ((cdata[1] & 0x80) >> 7)),
|
|
|
|
((cdata[1] & 0x78) >> 3));
|
|
|
|
|
2010-10-14 09:24:42 +00:00
|
|
|
if (!gst_faad_open_decoder (faad))
|
|
|
|
goto open_failed;
|
2005-08-08 19:20:02 +00:00
|
|
|
/* someone forgot that char can be unsigned when writing the API */
|
2006-10-06 15:49:39 +00:00
|
|
|
if ((gint8) faacDecInit2 (faad->handle, cdata, csize, &samplerate,
|
2006-07-16 14:46:02 +00:00
|
|
|
&channels) < 0)
|
|
|
|
goto init_failed;
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
|
2009-01-23 14:00:10 +00:00
|
|
|
if (channels != ((cdata[1] & 0x78) >> 3)) {
|
|
|
|
/* https://bugs.launchpad.net/ubuntu/+source/faad2/+bug/290259 */
|
|
|
|
GST_WARNING_OBJECT (faad,
|
|
|
|
"buggy faad version, wrong nr of channels %d instead of %d", channels,
|
|
|
|
((cdata[1] & 0x78) >> 3));
|
|
|
|
}
|
|
|
|
|
2007-08-16 11:34:54 +00:00
|
|
|
GST_DEBUG_OBJECT (faad, "codec_data init: channels=%u, rate=%u", channels,
|
2009-10-12 10:29:44 +00:00
|
|
|
(guint32) samplerate);
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
|
2005-08-08 19:20:02 +00:00
|
|
|
/* not updating these here, so they are updated in the
|
|
|
|
* chain function, and new caps are created etc. */
|
|
|
|
faad->samplerate = 0;
|
|
|
|
faad->channels = 0;
|
|
|
|
|
|
|
|
faad->init = TRUE;
|
2012-01-25 17:49:58 +00:00
|
|
|
gst_buffer_unmap (buf, &map);
|
2006-01-27 12:47:12 +00:00
|
|
|
} else if ((value = gst_structure_get_value (str, "framed")) &&
|
|
|
|
g_value_get_boolean (value) == TRUE) {
|
|
|
|
faad->packetised = TRUE;
|
2010-10-12 16:17:27 +00:00
|
|
|
faad->init = FALSE;
|
2007-08-16 11:34:54 +00:00
|
|
|
GST_DEBUG_OBJECT (faad, "we have packetized audio");
|
2005-08-08 19:20:02 +00:00
|
|
|
} else {
|
|
|
|
faad->init = FALSE;
|
|
|
|
}
|
2005-07-19 20:51:15 +00:00
|
|
|
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
faad->fake_codec_data[0] = 0;
|
|
|
|
faad->fake_codec_data[1] = 0;
|
|
|
|
|
2010-02-11 19:21:17 +00:00
|
|
|
if (faad->packetised && !faad->init) {
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
gint rate, channels;
|
|
|
|
|
|
|
|
if (gst_structure_get_int (str, "rate", &rate) &&
|
|
|
|
gst_structure_get_int (str, "channels", &channels)) {
|
|
|
|
gint rate_idx, profile;
|
|
|
|
|
2006-05-03 10:25:46 +00:00
|
|
|
profile = 3; /* 0=MAIN, 1=LC, 2=SSR, 3=LTP */
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
rate_idx = aac_rate_idx (rate);
|
|
|
|
|
|
|
|
faad->fake_codec_data[0] = ((profile + 1) << 3) | ((rate_idx & 0xE) >> 1);
|
|
|
|
faad->fake_codec_data[1] = ((rate_idx & 0x1) << 7) | (channels << 3);
|
2006-05-03 10:25:46 +00:00
|
|
|
GST_LOG_OBJECT (faad, "created fake codec data (%u,%u): 0x%x 0x%x", rate,
|
|
|
|
channels, (int) faad->fake_codec_data[0],
|
|
|
|
(int) faad->fake_codec_data[1]);
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-07-19 20:51:15 +00:00
|
|
|
return TRUE;
|
2006-07-16 14:46:02 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
2006-10-06 15:49:39 +00:00
|
|
|
wrong_length:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (faad, "codec_data less than 2 bytes long");
|
2012-01-25 17:49:58 +00:00
|
|
|
gst_buffer_unmap (buf, &map);
|
2006-10-06 15:49:39 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2010-10-14 09:24:42 +00:00
|
|
|
open_failed:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (faad, "failed to create decoder");
|
2012-01-25 17:49:58 +00:00
|
|
|
gst_buffer_unmap (buf, &map);
|
2010-10-14 09:24:42 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2006-07-16 14:46:02 +00:00
|
|
|
init_failed:
|
|
|
|
{
|
|
|
|
GST_DEBUG_OBJECT (faad, "faacDecInit2() failed");
|
2012-01-25 17:49:58 +00:00
|
|
|
gst_buffer_unmap (buf, &map);
|
2006-07-16 14:46:02 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2005-07-19 20:51:15 +00:00
|
|
|
}
|
|
|
|
|
2012-01-05 09:23:07 +00:00
|
|
|
static gboolean
|
|
|
|
gst_faad_chanpos_to_gst (GstFaad * faad, guchar * fpos,
|
|
|
|
GstAudioChannelPosition * pos, guint num)
|
Surround sound support.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
(gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init):
* ext/alsa/gstalsa.c: (gst_alsa_get_caps):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_channels),
(gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init):
* ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst),
(gst_faad_chanpos_to_gst), (gst_faad_sinkconnect),
(gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain),
(gst_faad_change_state), (plugin_init):
* ext/faad/gstfaad.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
* gst-libs/gst/audio/Makefile.am:
* gst-libs/gst/audio/audio.c: (plugin_init):
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions),
(gst_audio_get_channel_positions),
(gst_audio_set_channel_positions),
(gst_audio_set_structure_channel_positions_list),
(add_list_to_struct), (gst_audio_set_caps_channel_positions_list),
(gst_audio_fixate_channel_positions):
* gst-libs/gst/audio/multichannel.h:
* gst-libs/gst/audio/testchannels.c: (main):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_getcaps),
(gst_audio_convert_parse_caps), (gst_audio_convert_link),
(gst_audio_convert_fixate), (gst_audio_convert_channels):
* gst/audioconvert/plugin.c: (plugin_init):
Surround sound support.
2004-11-25 20:36:29 +00:00
|
|
|
{
|
|
|
|
guint n;
|
2005-12-09 15:30:21 +00:00
|
|
|
gboolean unknown_channel = FALSE;
|
Surround sound support.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
(gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init):
* ext/alsa/gstalsa.c: (gst_alsa_get_caps):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_channels),
(gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init):
* ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst),
(gst_faad_chanpos_to_gst), (gst_faad_sinkconnect),
(gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain),
(gst_faad_change_state), (plugin_init):
* ext/faad/gstfaad.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
* gst-libs/gst/audio/Makefile.am:
* gst-libs/gst/audio/audio.c: (plugin_init):
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions),
(gst_audio_get_channel_positions),
(gst_audio_set_channel_positions),
(gst_audio_set_structure_channel_positions_list),
(add_list_to_struct), (gst_audio_set_caps_channel_positions_list),
(gst_audio_fixate_channel_positions):
* gst-libs/gst/audio/multichannel.h:
* gst-libs/gst/audio/testchannels.c: (main):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_getcaps),
(gst_audio_convert_parse_caps), (gst_audio_convert_link),
(gst_audio_convert_fixate), (gst_audio_convert_channels):
* gst/audioconvert/plugin.c: (plugin_init):
Surround sound support.
2004-11-25 20:36:29 +00:00
|
|
|
|
2007-09-19 21:18:27 +00:00
|
|
|
/* special handling for the common cases for mono and stereo */
|
|
|
|
if (num == 1 && fpos[0] == FRONT_CHANNEL_CENTER) {
|
|
|
|
GST_DEBUG_OBJECT (faad, "mono common case; won't set channel positions");
|
2012-01-05 09:23:07 +00:00
|
|
|
pos[0] = GST_AUDIO_CHANNEL_POSITION_MONO;
|
|
|
|
return TRUE;
|
2007-09-19 21:18:27 +00:00
|
|
|
} else if (num == 2 && fpos[0] == FRONT_CHANNEL_LEFT
|
|
|
|
&& fpos[1] == FRONT_CHANNEL_RIGHT) {
|
|
|
|
GST_DEBUG_OBJECT (faad, "stereo common case; won't set channel positions");
|
2012-01-05 09:23:07 +00:00
|
|
|
pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
|
|
|
|
pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
|
|
|
|
return TRUE;
|
2007-09-19 21:18:27 +00:00
|
|
|
}
|
|
|
|
|
Surround sound support.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
(gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init):
* ext/alsa/gstalsa.c: (gst_alsa_get_caps):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_channels),
(gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init):
* ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst),
(gst_faad_chanpos_to_gst), (gst_faad_sinkconnect),
(gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain),
(gst_faad_change_state), (plugin_init):
* ext/faad/gstfaad.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
* gst-libs/gst/audio/Makefile.am:
* gst-libs/gst/audio/audio.c: (plugin_init):
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions),
(gst_audio_get_channel_positions),
(gst_audio_set_channel_positions),
(gst_audio_set_structure_channel_positions_list),
(add_list_to_struct), (gst_audio_set_caps_channel_positions_list),
(gst_audio_fixate_channel_positions):
* gst-libs/gst/audio/multichannel.h:
* gst-libs/gst/audio/testchannels.c: (main):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_getcaps),
(gst_audio_convert_parse_caps), (gst_audio_convert_link),
(gst_audio_convert_fixate), (gst_audio_convert_channels):
* gst/audioconvert/plugin.c: (plugin_init):
Surround sound support.
2004-11-25 20:36:29 +00:00
|
|
|
for (n = 0; n < num; n++) {
|
2007-09-19 21:18:27 +00:00
|
|
|
GST_DEBUG_OBJECT (faad, "faad channel %d as %d", n, fpos[n]);
|
Surround sound support.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
(gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init):
* ext/alsa/gstalsa.c: (gst_alsa_get_caps):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_channels),
(gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init):
* ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst),
(gst_faad_chanpos_to_gst), (gst_faad_sinkconnect),
(gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain),
(gst_faad_change_state), (plugin_init):
* ext/faad/gstfaad.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
* gst-libs/gst/audio/Makefile.am:
* gst-libs/gst/audio/audio.c: (plugin_init):
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions),
(gst_audio_get_channel_positions),
(gst_audio_set_channel_positions),
(gst_audio_set_structure_channel_positions_list),
(add_list_to_struct), (gst_audio_set_caps_channel_positions_list),
(gst_audio_fixate_channel_positions):
* gst-libs/gst/audio/multichannel.h:
* gst-libs/gst/audio/testchannels.c: (main):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_getcaps),
(gst_audio_convert_parse_caps), (gst_audio_convert_link),
(gst_audio_convert_fixate), (gst_audio_convert_channels):
* gst/audioconvert/plugin.c: (plugin_init):
Surround sound support.
2004-11-25 20:36:29 +00:00
|
|
|
switch (fpos[n]) {
|
|
|
|
case FRONT_CHANNEL_LEFT:
|
|
|
|
pos[n] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
|
|
|
|
break;
|
|
|
|
case FRONT_CHANNEL_RIGHT:
|
|
|
|
pos[n] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
|
|
|
|
break;
|
|
|
|
case FRONT_CHANNEL_CENTER:
|
2004-12-03 15:34:19 +00:00
|
|
|
/* argh, mono = center */
|
|
|
|
if (num == 1)
|
2012-01-05 09:23:07 +00:00
|
|
|
pos[n] = GST_AUDIO_CHANNEL_POSITION_MONO;
|
2004-12-03 15:34:19 +00:00
|
|
|
else
|
|
|
|
pos[n] = GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER;
|
Surround sound support.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
(gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init):
* ext/alsa/gstalsa.c: (gst_alsa_get_caps):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_channels),
(gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init):
* ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst),
(gst_faad_chanpos_to_gst), (gst_faad_sinkconnect),
(gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain),
(gst_faad_change_state), (plugin_init):
* ext/faad/gstfaad.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
* gst-libs/gst/audio/Makefile.am:
* gst-libs/gst/audio/audio.c: (plugin_init):
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions),
(gst_audio_get_channel_positions),
(gst_audio_set_channel_positions),
(gst_audio_set_structure_channel_positions_list),
(add_list_to_struct), (gst_audio_set_caps_channel_positions_list),
(gst_audio_fixate_channel_positions):
* gst-libs/gst/audio/multichannel.h:
* gst-libs/gst/audio/testchannels.c: (main):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_getcaps),
(gst_audio_convert_parse_caps), (gst_audio_convert_link),
(gst_audio_convert_fixate), (gst_audio_convert_channels):
* gst/audioconvert/plugin.c: (plugin_init):
Surround sound support.
2004-11-25 20:36:29 +00:00
|
|
|
break;
|
|
|
|
case SIDE_CHANNEL_LEFT:
|
|
|
|
pos[n] = GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT;
|
|
|
|
break;
|
|
|
|
case SIDE_CHANNEL_RIGHT:
|
|
|
|
pos[n] = GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT;
|
|
|
|
break;
|
|
|
|
case BACK_CHANNEL_LEFT:
|
|
|
|
pos[n] = GST_AUDIO_CHANNEL_POSITION_REAR_LEFT;
|
|
|
|
break;
|
|
|
|
case BACK_CHANNEL_RIGHT:
|
|
|
|
pos[n] = GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT;
|
|
|
|
break;
|
|
|
|
case BACK_CHANNEL_CENTER:
|
|
|
|
pos[n] = GST_AUDIO_CHANNEL_POSITION_REAR_CENTER;
|
|
|
|
break;
|
|
|
|
case LFE_CHANNEL:
|
2012-01-05 09:23:07 +00:00
|
|
|
pos[n] = GST_AUDIO_CHANNEL_POSITION_LFE1;
|
Surround sound support.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
(gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init):
* ext/alsa/gstalsa.c: (gst_alsa_get_caps):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_channels),
(gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init):
* ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst),
(gst_faad_chanpos_to_gst), (gst_faad_sinkconnect),
(gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain),
(gst_faad_change_state), (plugin_init):
* ext/faad/gstfaad.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
* gst-libs/gst/audio/Makefile.am:
* gst-libs/gst/audio/audio.c: (plugin_init):
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions),
(gst_audio_get_channel_positions),
(gst_audio_set_channel_positions),
(gst_audio_set_structure_channel_positions_list),
(add_list_to_struct), (gst_audio_set_caps_channel_positions_list),
(gst_audio_fixate_channel_positions):
* gst-libs/gst/audio/multichannel.h:
* gst-libs/gst/audio/testchannels.c: (main):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_getcaps),
(gst_audio_convert_parse_caps), (gst_audio_convert_link),
(gst_audio_convert_fixate), (gst_audio_convert_channels):
* gst/audioconvert/plugin.c: (plugin_init):
Surround sound support.
2004-11-25 20:36:29 +00:00
|
|
|
break;
|
|
|
|
default:
|
2007-09-19 21:18:27 +00:00
|
|
|
GST_DEBUG_OBJECT (faad, "unknown channel %d at %d", fpos[n], n);
|
2005-12-09 15:30:21 +00:00
|
|
|
unknown_channel = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (unknown_channel) {
|
2006-01-27 12:47:12 +00:00
|
|
|
switch (num) {
|
|
|
|
case 1:{
|
2007-09-19 21:18:27 +00:00
|
|
|
GST_DEBUG_OBJECT (faad,
|
|
|
|
"FAAD reports unknown 1 channel mapping. Forcing to mono");
|
2012-01-05 09:23:07 +00:00
|
|
|
pos[0] = GST_AUDIO_CHANNEL_POSITION_MONO;
|
2006-01-27 12:47:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:{
|
2007-09-19 21:18:27 +00:00
|
|
|
GST_DEBUG_OBJECT (faad,
|
|
|
|
"FAAD reports unknown 2 channel mapping. Forcing to stereo");
|
2012-01-05 09:23:07 +00:00
|
|
|
pos[0] = GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT;
|
|
|
|
pos[1] = GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT;
|
2006-01-27 12:47:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:{
|
2010-02-10 18:14:19 +00:00
|
|
|
GST_WARNING_OBJECT (faad,
|
|
|
|
"Unsupported FAAD channel position 0x%x encountered", fpos[n]);
|
2012-01-05 09:23:07 +00:00
|
|
|
return FALSE;
|
2006-01-27 12:47:12 +00:00
|
|
|
}
|
Surround sound support.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
(gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init):
* ext/alsa/gstalsa.c: (gst_alsa_get_caps):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_channels),
(gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init):
* ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst),
(gst_faad_chanpos_to_gst), (gst_faad_sinkconnect),
(gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain),
(gst_faad_change_state), (plugin_init):
* ext/faad/gstfaad.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
* gst-libs/gst/audio/Makefile.am:
* gst-libs/gst/audio/audio.c: (plugin_init):
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions),
(gst_audio_get_channel_positions),
(gst_audio_set_channel_positions),
(gst_audio_set_structure_channel_positions_list),
(add_list_to_struct), (gst_audio_set_caps_channel_positions_list),
(gst_audio_fixate_channel_positions):
* gst-libs/gst/audio/multichannel.h:
* gst-libs/gst/audio/testchannels.c: (main):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_getcaps),
(gst_audio_convert_parse_caps), (gst_audio_convert_link),
(gst_audio_convert_fixate), (gst_audio_convert_channels):
* gst/audioconvert/plugin.c: (plugin_init):
Surround sound support.
2004-11-25 20:36:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-05 09:23:07 +00:00
|
|
|
return TRUE;
|
Surround sound support.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
(gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init):
* ext/alsa/gstalsa.c: (gst_alsa_get_caps):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_channels),
(gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init):
* ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst),
(gst_faad_chanpos_to_gst), (gst_faad_sinkconnect),
(gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain),
(gst_faad_change_state), (plugin_init):
* ext/faad/gstfaad.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
* gst-libs/gst/audio/Makefile.am:
* gst-libs/gst/audio/audio.c: (plugin_init):
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions),
(gst_audio_get_channel_positions),
(gst_audio_set_channel_positions),
(gst_audio_set_structure_channel_positions_list),
(add_list_to_struct), (gst_audio_set_caps_channel_positions_list),
(gst_audio_fixate_channel_positions):
* gst-libs/gst/audio/multichannel.h:
* gst-libs/gst/audio/testchannels.c: (main):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_getcaps),
(gst_audio_convert_parse_caps), (gst_audio_convert_link),
(gst_audio_convert_fixate), (gst_audio_convert_channels):
* gst/audioconvert/plugin.c: (plugin_init):
Surround sound support.
2004-11-25 20:36:29 +00:00
|
|
|
}
|
|
|
|
|
2005-08-08 19:20:02 +00:00
|
|
|
static gboolean
|
2006-05-17 09:39:53 +00:00
|
|
|
gst_faad_update_caps (GstFaad * faad, faacDecFrameInfo * info)
|
2005-08-08 19:20:02 +00:00
|
|
|
{
|
2006-05-17 09:39:53 +00:00
|
|
|
gboolean ret;
|
2010-02-10 17:46:16 +00:00
|
|
|
gboolean fmt_change = FALSE;
|
2012-01-05 09:23:07 +00:00
|
|
|
GstAudioInfo ainfo;
|
2012-03-20 15:34:33 +00:00
|
|
|
gint i;
|
2014-06-06 12:57:30 +00:00
|
|
|
GstAudioChannelPosition position[6];
|
2010-02-10 17:46:16 +00:00
|
|
|
|
|
|
|
/* see if we need to renegotiate */
|
|
|
|
if (info->samplerate != faad->samplerate ||
|
|
|
|
info->channels != faad->channels || !faad->channel_positions) {
|
|
|
|
fmt_change = TRUE;
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < info->channels; i++) {
|
2012-01-05 09:23:07 +00:00
|
|
|
if (info->channel_position[i] != faad->channel_positions[i]) {
|
2010-02-10 17:46:16 +00:00
|
|
|
fmt_change = TRUE;
|
2012-01-05 09:23:07 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-02-10 17:46:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-09 13:59:58 +00:00
|
|
|
if (G_LIKELY (gst_pad_has_current_caps (GST_AUDIO_DECODER_SRC_PAD (faad))
|
|
|
|
&& !fmt_change))
|
2010-02-10 17:46:16 +00:00
|
|
|
return TRUE;
|
2005-08-08 19:20:02 +00:00
|
|
|
|
2012-01-05 09:23:07 +00:00
|
|
|
|
2005-08-08 19:20:02 +00:00
|
|
|
/* store new negotiation information */
|
|
|
|
faad->samplerate = info->samplerate;
|
|
|
|
faad->channels = info->channels;
|
|
|
|
g_free (faad->channel_positions);
|
|
|
|
faad->channel_positions = g_memdup (info->channel_position, faad->channels);
|
|
|
|
|
|
|
|
faad->bps = 16 / 8;
|
|
|
|
|
2012-01-05 09:23:07 +00:00
|
|
|
if (!gst_faad_chanpos_to_gst (faad, faad->channel_positions,
|
|
|
|
faad->aac_positions, faad->channels)) {
|
2005-12-09 15:30:21 +00:00
|
|
|
GST_DEBUG_OBJECT (faad, "Could not map channel positions");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2014-06-06 12:57:30 +00:00
|
|
|
|
|
|
|
memcpy (position, faad->aac_positions, sizeof (position));
|
|
|
|
gst_audio_channel_positions_to_valid_order (position, faad->channels);
|
|
|
|
memcpy (faad->gst_positions, position,
|
2012-01-05 09:23:07 +00:00
|
|
|
faad->channels * sizeof (GstAudioChannelPosition));
|
|
|
|
|
2012-03-20 15:34:33 +00:00
|
|
|
/* get the remap table */
|
|
|
|
memset (faad->reorder_map, 0, sizeof (faad->reorder_map));
|
|
|
|
faad->need_reorder = FALSE;
|
|
|
|
if (gst_audio_get_channel_reorder_map (faad->channels, faad->aac_positions,
|
|
|
|
faad->gst_positions, faad->reorder_map)) {
|
|
|
|
for (i = 0; i < faad->channels; i++) {
|
2012-03-20 15:44:17 +00:00
|
|
|
GST_DEBUG_OBJECT (faad, "remap %d -> %d", i, faad->reorder_map[i]);
|
2012-03-20 15:34:33 +00:00
|
|
|
if (faad->reorder_map[i] != i) {
|
|
|
|
faad->need_reorder = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-06 12:57:30 +00:00
|
|
|
/* FIXME: Use the GstAudioInfo of GstAudioDecoder for all of this */
|
|
|
|
gst_audio_info_init (&ainfo);
|
|
|
|
gst_audio_info_set_format (&ainfo, GST_AUDIO_FORMAT_S16, faad->samplerate,
|
|
|
|
faad->channels, position);
|
|
|
|
|
2012-02-01 15:26:01 +00:00
|
|
|
ret = gst_audio_decoder_set_output_format (GST_AUDIO_DECODER (faad), &ainfo);
|
2005-08-08 19:20:02 +00:00
|
|
|
|
2006-05-17 09:39:53 +00:00
|
|
|
return ret;
|
2005-08-08 19:20:02 +00:00
|
|
|
}
|
|
|
|
|
2006-01-27 12:47:12 +00:00
|
|
|
/*
|
|
|
|
* Find syncpoint in ADTS/ADIF stream. Doesn't work for raw,
|
|
|
|
* packetized streams. Be careful when calling.
|
|
|
|
* Returns FALSE on no-sync, fills offset/length if one/two
|
|
|
|
* syncpoints are found, only returns TRUE when it finds two
|
|
|
|
* subsequent syncpoints (similar to mp3 typefinding in
|
|
|
|
* gst/typefind/) for ADTS because 12 bits isn't very reliable.
|
|
|
|
*/
|
|
|
|
static gboolean
|
2011-09-22 07:49:21 +00:00
|
|
|
gst_faad_sync (GstFaad * faad, const guint8 * data, guint size, gboolean next,
|
|
|
|
gint * off, gint * length)
|
2006-01-27 12:47:12 +00:00
|
|
|
{
|
2010-02-10 20:12:07 +00:00
|
|
|
guint n = 0;
|
2006-01-27 12:47:12 +00:00
|
|
|
gint snc;
|
2010-02-10 20:12:07 +00:00
|
|
|
gboolean ret = FALSE;
|
2011-09-23 09:10:37 +00:00
|
|
|
guint len = 0;
|
2006-01-27 12:47:12 +00:00
|
|
|
|
2010-02-10 18:14:19 +00:00
|
|
|
GST_LOG_OBJECT (faad, "Finding syncpoint");
|
2006-01-27 12:47:12 +00:00
|
|
|
|
2006-07-16 14:46:02 +00:00
|
|
|
/* check for too small a buffer */
|
|
|
|
if (size < 3)
|
2010-02-10 20:12:07 +00:00
|
|
|
goto exit;
|
2006-07-16 14:46:02 +00:00
|
|
|
|
2006-01-27 12:47:12 +00:00
|
|
|
for (n = 0; n < size - 3; n++) {
|
|
|
|
snc = GST_READ_UINT16_BE (&data[n]);
|
|
|
|
if ((snc & 0xfff6) == 0xfff0) {
|
|
|
|
/* we have an ADTS syncpoint. Parse length and find
|
|
|
|
* next syncpoint. */
|
2010-02-10 18:14:19 +00:00
|
|
|
GST_LOG_OBJECT (faad,
|
|
|
|
"Found one ADTS syncpoint at offset 0x%x, tracing next...", n);
|
2006-01-27 12:47:12 +00:00
|
|
|
|
|
|
|
if (size - n < 5) {
|
2010-02-10 18:14:19 +00:00
|
|
|
GST_LOG_OBJECT (faad, "Not enough data to parse ADTS header");
|
2010-02-10 20:12:07 +00:00
|
|
|
break;
|
2006-01-27 12:47:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
len = ((data[n + 3] & 0x03) << 11) |
|
|
|
|
(data[n + 4] << 3) | ((data[n + 5] & 0xe0) >> 5);
|
|
|
|
if (n + len + 2 >= size) {
|
2010-02-10 22:29:23 +00:00
|
|
|
GST_LOG_OBJECT (faad, "Frame size %d, next frame is not within reach",
|
|
|
|
len);
|
|
|
|
if (next) {
|
|
|
|
break;
|
|
|
|
} else if (n + len <= size) {
|
|
|
|
GST_LOG_OBJECT (faad, "but have complete frame and no next frame; "
|
|
|
|
"accept ADTS syncpoint at offset 0x%x (framelen %u)", n, len);
|
|
|
|
ret = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2006-01-27 12:47:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
snc = GST_READ_UINT16_BE (&data[n + len]);
|
|
|
|
if ((snc & 0xfff6) == 0xfff0) {
|
2010-02-10 18:14:19 +00:00
|
|
|
GST_LOG_OBJECT (faad,
|
|
|
|
"Found ADTS syncpoint at offset 0x%x (framelen %u)", n, len);
|
2010-02-10 20:12:07 +00:00
|
|
|
ret = TRUE;
|
|
|
|
break;
|
2006-01-27 12:47:12 +00:00
|
|
|
}
|
|
|
|
|
2010-02-10 18:14:19 +00:00
|
|
|
GST_LOG_OBJECT (faad, "No next frame found... (should be at 0x%x)",
|
|
|
|
n + len);
|
2006-01-27 12:47:12 +00:00
|
|
|
} else if (!memcmp (&data[n], "ADIF", 4)) {
|
|
|
|
/* we have an ADIF syncpoint. 4 bytes is enough. */
|
2010-02-10 18:14:19 +00:00
|
|
|
GST_LOG_OBJECT (faad, "Found ADIF syncpoint at offset 0x%x", n);
|
2010-02-10 20:12:07 +00:00
|
|
|
ret = TRUE;
|
|
|
|
break;
|
2006-01-27 12:47:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-02-10 20:12:07 +00:00
|
|
|
exit:
|
2011-09-23 09:10:37 +00:00
|
|
|
|
2010-02-10 20:12:07 +00:00
|
|
|
*off = n;
|
2006-01-27 12:47:12 +00:00
|
|
|
|
2011-09-23 09:10:37 +00:00
|
|
|
if (ret) {
|
|
|
|
*length = len;
|
|
|
|
} else {
|
2010-02-10 20:12:07 +00:00
|
|
|
GST_LOG_OBJECT (faad, "Found no syncpoint");
|
2011-09-23 09:10:37 +00:00
|
|
|
}
|
2010-02-10 20:12:07 +00:00
|
|
|
|
|
|
|
return ret;
|
2006-01-27 12:47:12 +00:00
|
|
|
}
|
|
|
|
|
2006-05-03 10:25:46 +00:00
|
|
|
static gboolean
|
|
|
|
looks_like_valid_header (guint8 * input_data, guint input_size)
|
|
|
|
{
|
2008-03-08 04:27:03 +00:00
|
|
|
if (input_size < 4)
|
2006-05-03 10:25:46 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2008-03-08 04:27:03 +00:00
|
|
|
if (input_data[0] == 'A'
|
|
|
|
&& input_data[1] == 'D' && input_data[2] == 'I' && input_data[3] == 'F')
|
|
|
|
/* ADIF type header */
|
|
|
|
return TRUE;
|
2006-05-03 10:25:46 +00:00
|
|
|
|
2008-03-08 04:27:03 +00:00
|
|
|
if (input_data[0] == 0xff && (input_data[1] >> 4) == 0xf)
|
|
|
|
/* ADTS type header */
|
|
|
|
return TRUE;
|
2006-05-03 10:25:46 +00:00
|
|
|
|
2008-03-08 04:27:03 +00:00
|
|
|
return FALSE;
|
2006-05-03 10:25:46 +00:00
|
|
|
}
|
|
|
|
|
2011-09-22 07:49:21 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_faad_parse (GstAudioDecoder * dec, GstAdapter * adapter,
|
|
|
|
gint * offset, gint * length)
|
|
|
|
{
|
|
|
|
GstFaad *faad;
|
|
|
|
const guint8 *data;
|
|
|
|
guint size;
|
|
|
|
gboolean sync, eos;
|
|
|
|
|
|
|
|
faad = GST_FAAD (dec);
|
|
|
|
|
|
|
|
size = gst_adapter_available (adapter);
|
2011-09-23 08:57:01 +00:00
|
|
|
g_return_val_if_fail (size > 0, GST_FLOW_ERROR);
|
2011-09-22 07:49:21 +00:00
|
|
|
|
|
|
|
gst_audio_decoder_get_parse_state (dec, &sync, &eos);
|
|
|
|
|
|
|
|
if (faad->packetised) {
|
|
|
|
*offset = 0;
|
|
|
|
*length = size;
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
} else {
|
2011-09-27 11:22:31 +00:00
|
|
|
gboolean ret;
|
|
|
|
|
|
|
|
data = gst_adapter_map (adapter, size);
|
|
|
|
ret = gst_faad_sync (faad, data, size, !eos, offset, length);
|
2011-11-10 17:25:53 +00:00
|
|
|
gst_adapter_unmap (adapter);
|
2011-09-27 11:22:31 +00:00
|
|
|
|
2012-01-03 14:26:54 +00:00
|
|
|
return (ret ? GST_FLOW_OK : GST_FLOW_EOS);
|
2011-09-22 07:49:21 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-10 20:37:12 +00:00
|
|
|
|
2005-07-19 20:51:15 +00:00
|
|
|
static GstFlowReturn
|
2011-09-22 07:49:21 +00:00
|
|
|
gst_faad_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
|
2003-11-21 21:20:42 +00:00
|
|
|
{
|
2011-09-22 07:49:21 +00:00
|
|
|
GstFaad *faad;
|
2005-07-19 20:51:15 +00:00
|
|
|
GstFlowReturn ret = GST_FLOW_OK;
|
2012-01-25 17:49:58 +00:00
|
|
|
GstMapInfo map;
|
2011-09-27 11:22:31 +00:00
|
|
|
gsize input_size;
|
2004-10-01 13:00:41 +00:00
|
|
|
guchar *input_data;
|
2005-07-19 20:51:15 +00:00
|
|
|
GstBuffer *outbuf;
|
2005-08-08 19:20:02 +00:00
|
|
|
faacDecFrameInfo info;
|
2003-11-21 21:20:42 +00:00
|
|
|
void *out;
|
2008-06-02 10:18:25 +00:00
|
|
|
|
2011-09-22 07:49:21 +00:00
|
|
|
faad = GST_FAAD (dec);
|
2010-02-10 20:12:07 +00:00
|
|
|
|
2011-09-22 07:49:21 +00:00
|
|
|
/* no fancy draining */
|
|
|
|
if (G_UNLIKELY (!buffer))
|
|
|
|
return GST_FLOW_OK;
|
2010-09-29 08:08:17 +00:00
|
|
|
|
2012-01-25 17:49:58 +00:00
|
|
|
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
|
|
|
input_data = map.data;
|
|
|
|
input_size = map.size;
|
2006-01-27 12:47:12 +00:00
|
|
|
|
2010-10-12 16:17:27 +00:00
|
|
|
init:
|
Surround sound support.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
(gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init):
* ext/alsa/gstalsa.c: (gst_alsa_get_caps):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_channels),
(gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init):
* ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst),
(gst_faad_chanpos_to_gst), (gst_faad_sinkconnect),
(gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain),
(gst_faad_change_state), (plugin_init):
* ext/faad/gstfaad.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
* gst-libs/gst/audio/Makefile.am:
* gst-libs/gst/audio/audio.c: (plugin_init):
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions),
(gst_audio_get_channel_positions),
(gst_audio_set_channel_positions),
(gst_audio_set_structure_channel_positions_list),
(add_list_to_struct), (gst_audio_set_caps_channel_positions_list),
(gst_audio_fixate_channel_positions):
* gst-libs/gst/audio/multichannel.h:
* gst-libs/gst/audio/testchannels.c: (main):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_getcaps),
(gst_audio_convert_parse_caps), (gst_audio_convert_link),
(gst_audio_convert_fixate), (gst_audio_convert_channels):
* gst/audioconvert/plugin.c: (plugin_init):
Surround sound support.
2004-11-25 20:36:29 +00:00
|
|
|
/* init if not already done during capsnego */
|
|
|
|
if (!faad->init) {
|
2009-03-06 11:42:50 +00:00
|
|
|
unsigned long rate;
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
guint8 ch;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (faad, "initialising ...");
|
2010-10-14 09:24:42 +00:00
|
|
|
if (!gst_faad_open_decoder (faad))
|
|
|
|
goto open_failed;
|
2006-05-03 10:25:46 +00:00
|
|
|
/* We check if the first data looks like it might plausibly contain
|
|
|
|
* appropriate initialisation info... if not, we use our fake_codec_data
|
|
|
|
*/
|
|
|
|
if (looks_like_valid_header (input_data, input_size) || !faad->packetised) {
|
|
|
|
if (faacDecInit (faad->handle, input_data, input_size, &rate, &ch) < 0)
|
|
|
|
goto init_failed;
|
|
|
|
|
2009-10-12 10:29:44 +00:00
|
|
|
GST_DEBUG_OBJECT (faad, "faacDecInit() ok: rate=%u,channels=%u",
|
|
|
|
(guint32) rate, ch);
|
2006-05-03 10:25:46 +00:00
|
|
|
} else {
|
|
|
|
if ((gint8) faacDecInit2 (faad->handle, faad->fake_codec_data, 2,
|
|
|
|
&rate, &ch) < 0) {
|
|
|
|
goto init2_failed;
|
|
|
|
}
|
2009-10-12 10:29:44 +00:00
|
|
|
GST_DEBUG_OBJECT (faad, "faacDecInit2() ok: rate=%u,channels=%u",
|
|
|
|
(guint32) rate, ch);
|
2006-05-03 10:25:46 +00:00
|
|
|
}
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
|
Surround sound support.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
(gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init):
* ext/alsa/gstalsa.c: (gst_alsa_get_caps):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_channels),
(gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init):
* ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst),
(gst_faad_chanpos_to_gst), (gst_faad_sinkconnect),
(gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain),
(gst_faad_change_state), (plugin_init):
* ext/faad/gstfaad.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
* gst-libs/gst/audio/Makefile.am:
* gst-libs/gst/audio/audio.c: (plugin_init):
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions),
(gst_audio_get_channel_positions),
(gst_audio_set_channel_positions),
(gst_audio_set_structure_channel_positions_list),
(add_list_to_struct), (gst_audio_set_caps_channel_positions_list),
(gst_audio_fixate_channel_positions):
* gst-libs/gst/audio/multichannel.h:
* gst-libs/gst/audio/testchannels.c: (main):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_getcaps),
(gst_audio_convert_parse_caps), (gst_audio_convert_link),
(gst_audio_convert_fixate), (gst_audio_convert_channels):
* gst/audioconvert/plugin.c: (plugin_init):
Surround sound support.
2004-11-25 20:36:29 +00:00
|
|
|
faad->init = TRUE;
|
2003-11-21 21:20:42 +00:00
|
|
|
|
2005-08-08 19:20:02 +00:00
|
|
|
/* make sure we create new caps below */
|
|
|
|
faad->samplerate = 0;
|
|
|
|
faad->channels = 0;
|
2003-11-21 21:20:42 +00:00
|
|
|
}
|
2003-12-18 09:31:50 +00:00
|
|
|
|
Surround sound support.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
(gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init):
* ext/alsa/gstalsa.c: (gst_alsa_get_caps):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_channels),
(gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init):
* ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst),
(gst_faad_chanpos_to_gst), (gst_faad_sinkconnect),
(gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain),
(gst_faad_change_state), (plugin_init):
* ext/faad/gstfaad.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
* gst-libs/gst/audio/Makefile.am:
* gst-libs/gst/audio/audio.c: (plugin_init):
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions),
(gst_audio_get_channel_positions),
(gst_audio_set_channel_positions),
(gst_audio_set_structure_channel_positions_list),
(add_list_to_struct), (gst_audio_set_caps_channel_positions_list),
(gst_audio_fixate_channel_positions):
* gst-libs/gst/audio/multichannel.h:
* gst-libs/gst/audio/testchannels.c: (main):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_getcaps),
(gst_audio_convert_parse_caps), (gst_audio_convert_link),
(gst_audio_convert_fixate), (gst_audio_convert_channels):
* gst/audioconvert/plugin.c: (plugin_init):
Surround sound support.
2004-11-25 20:36:29 +00:00
|
|
|
/* decode cycle */
|
2006-01-27 12:47:12 +00:00
|
|
|
info.error = 0;
|
2005-02-21 18:58:46 +00:00
|
|
|
|
2011-09-22 07:49:21 +00:00
|
|
|
do {
|
2012-06-12 07:10:54 +00:00
|
|
|
GstMapInfo omap;
|
2005-02-21 18:58:46 +00:00
|
|
|
|
2011-09-22 07:49:21 +00:00
|
|
|
if (!faad->packetised) {
|
2010-10-12 16:17:27 +00:00
|
|
|
/* faad only really parses ADTS header at Init time, not when decoding,
|
|
|
|
* so monitor for changes and kick faad when needed */
|
|
|
|
if (GST_READ_UINT32_BE (input_data) >> 4 != faad->last_header >> 4) {
|
|
|
|
GST_DEBUG_OBJECT (faad, "ADTS header changed, forcing Init");
|
|
|
|
faad->last_header = GST_READ_UINT32_BE (input_data);
|
2010-10-14 09:24:42 +00:00
|
|
|
/* kick hard */
|
|
|
|
gst_faad_close_decoder (faad);
|
|
|
|
faad->init = FALSE;
|
2010-10-12 16:17:27 +00:00
|
|
|
goto init;
|
|
|
|
}
|
2005-02-21 18:58:46 +00:00
|
|
|
}
|
|
|
|
|
2010-02-10 20:12:07 +00:00
|
|
|
out = faacDecDecode (faad->handle, &info, input_data, input_size);
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
|
2012-08-02 12:40:55 +00:00
|
|
|
gst_buffer_unmap (buffer, &map);
|
|
|
|
buffer = NULL;
|
|
|
|
|
2006-10-06 15:49:39 +00:00
|
|
|
if (info.error > 0) {
|
2011-09-22 07:49:21 +00:00
|
|
|
/* give up on frame and bail out */
|
|
|
|
gst_audio_decoder_finish_frame (dec, NULL, 1);
|
|
|
|
goto decode_failed;
|
2004-10-01 13:00:41 +00:00
|
|
|
}
|
2004-03-10 05:45:23 +00:00
|
|
|
|
2010-02-11 19:21:17 +00:00
|
|
|
GST_LOG_OBJECT (faad, "%d bytes consumed, %d samples decoded",
|
|
|
|
(guint) info.bytesconsumed, (guint) info.samples);
|
|
|
|
|
2005-08-08 19:20:02 +00:00
|
|
|
if (out && info.samples > 0) {
|
2012-03-20 15:34:33 +00:00
|
|
|
guint channels, samples;
|
|
|
|
|
2010-02-10 17:46:16 +00:00
|
|
|
if (!gst_faad_update_caps (faad, &info))
|
|
|
|
goto negotiation_failed;
|
Surround sound support.
Original commit message from CVS:
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
(gst_a52dec_reneg), (gst_a52dec_loop), (plugin_init):
* ext/alsa/gstalsa.c: (gst_alsa_get_caps):
* ext/alsa/gstalsaplugin.c: (plugin_init):
* ext/dts/gstdtsdec.c: (gst_dtsdec_channels),
(gst_dtsdec_renegotiate), (gst_dtsdec_loop), (plugin_init):
* ext/faad/gstfaad.c: (gst_faad_init), (gst_faad_chanpos_from_gst),
(gst_faad_chanpos_to_gst), (gst_faad_sinkconnect),
(gst_faad_srcgetcaps), (gst_faad_srcconnect), (gst_faad_chain),
(gst_faad_change_state), (plugin_init):
* ext/faad/gstfaad.h:
* ext/vorbis/vorbis.c: (plugin_init):
* ext/vorbis/vorbisdec.c: (vorbis_dec_chain):
* gst-libs/gst/audio/Makefile.am:
* gst-libs/gst/audio/audio.c: (plugin_init):
* gst-libs/gst/audio/multichannel.c:
(gst_audio_check_channel_positions),
(gst_audio_get_channel_positions),
(gst_audio_set_channel_positions),
(gst_audio_set_structure_channel_positions_list),
(add_list_to_struct), (gst_audio_set_caps_channel_positions_list),
(gst_audio_fixate_channel_positions):
* gst-libs/gst/audio/multichannel.h:
* gst-libs/gst/audio/testchannels.c: (main):
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_getcaps),
(gst_audio_convert_parse_caps), (gst_audio_convert_link),
(gst_audio_convert_fixate), (gst_audio_convert_channels):
* gst/audioconvert/plugin.c: (plugin_init):
Surround sound support.
2004-11-25 20:36:29 +00:00
|
|
|
|
2010-02-10 17:46:16 +00:00
|
|
|
/* C's lovely propensity for int overflow.. */
|
|
|
|
if (info.samples > G_MAXUINT / faad->bps)
|
|
|
|
goto sample_overflow;
|
2008-03-18 10:12:40 +00:00
|
|
|
|
2012-03-20 15:34:33 +00:00
|
|
|
channels = faad->channels;
|
2011-09-22 07:49:21 +00:00
|
|
|
/* note: info.samples is total samples, not per channel */
|
2012-03-20 15:34:33 +00:00
|
|
|
samples = info.samples / channels;
|
|
|
|
|
2011-09-27 11:22:31 +00:00
|
|
|
/* FIXME, add bufferpool and allocator support to the base class */
|
2012-03-15 12:37:36 +00:00
|
|
|
outbuf = gst_buffer_new_allocate (NULL, info.samples * faad->bps, NULL);
|
2012-03-20 15:34:33 +00:00
|
|
|
|
2012-06-12 07:10:54 +00:00
|
|
|
gst_buffer_map (outbuf, &omap, GST_MAP_READWRITE);
|
2012-03-20 15:34:33 +00:00
|
|
|
if (faad->need_reorder) {
|
|
|
|
gint16 *dest, *src, i, j;
|
|
|
|
|
2012-06-12 07:10:54 +00:00
|
|
|
dest = (gint16 *) omap.data;
|
2012-03-20 15:34:33 +00:00
|
|
|
src = (gint16 *) out;
|
|
|
|
|
|
|
|
for (i = 0; i < samples; i++) {
|
|
|
|
for (j = 0; j < channels; j++) {
|
|
|
|
dest[faad->reorder_map[j]] = *src++;
|
|
|
|
}
|
|
|
|
dest += channels;
|
|
|
|
}
|
|
|
|
} else {
|
2012-06-12 07:10:54 +00:00
|
|
|
memcpy (omap.data, out, omap.size);
|
2012-03-20 15:34:33 +00:00
|
|
|
}
|
2012-06-12 07:10:54 +00:00
|
|
|
gst_buffer_unmap (outbuf, &omap);
|
2011-09-22 07:49:21 +00:00
|
|
|
|
|
|
|
ret = gst_audio_decoder_finish_frame (dec, outbuf, 1);
|
2010-09-29 08:08:17 +00:00
|
|
|
}
|
2011-09-22 07:49:21 +00:00
|
|
|
} while (FALSE);
|
2004-03-06 00:42:20 +00:00
|
|
|
|
2005-08-08 19:20:02 +00:00
|
|
|
out:
|
2012-06-12 07:10:54 +00:00
|
|
|
if (buffer)
|
|
|
|
gst_buffer_unmap (buffer, &map);
|
2011-09-27 11:22:31 +00:00
|
|
|
|
2005-07-19 20:51:15 +00:00
|
|
|
return ret;
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
2010-10-14 09:24:42 +00:00
|
|
|
open_failed:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (faad, STREAM, DECODE, (NULL),
|
|
|
|
("Failed to open decoder"));
|
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto out;
|
|
|
|
}
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
init_failed:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (faad, STREAM, DECODE, (NULL),
|
|
|
|
("Failed to init decoder from stream"));
|
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
init2_failed:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (faad, STREAM, DECODE, (NULL),
|
|
|
|
("%s() failed", (faad->handle) ? "faacDecInit2" : "faacDecOpen"));
|
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto out;
|
|
|
|
}
|
2010-02-10 20:49:00 +00:00
|
|
|
decode_failed:
|
|
|
|
{
|
2011-09-22 07:49:21 +00:00
|
|
|
GST_AUDIO_DECODER_ERROR (faad, 1, STREAM, DECODE, (NULL),
|
|
|
|
("decoding error: %s", faacDecGetErrorMessage (info.error)), ret);
|
2010-02-10 20:49:00 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2010-02-10 17:46:16 +00:00
|
|
|
negotiation_failed:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (faad, CORE, NEGOTIATION, (NULL),
|
|
|
|
("Setting caps on source pad failed"));
|
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
sample_overflow:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (faad, STREAM, DECODE, (NULL),
|
|
|
|
("Output buffer too large"));
|
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto out;
|
|
|
|
}
|
2011-09-22 07:49:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_faad_flush (GstAudioDecoder * dec, gboolean hard)
|
|
|
|
{
|
|
|
|
gst_faad_reset_stream_state (GST_FAAD (dec));
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_faad_open_decoder (GstFaad * faad)
|
|
|
|
{
|
|
|
|
faacDecConfiguration *conf;
|
|
|
|
|
|
|
|
faad->handle = faacDecOpen ();
|
|
|
|
|
|
|
|
if (faad->handle == NULL) {
|
|
|
|
GST_WARNING_OBJECT (faad, "faacDecOpen() failed");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
conf = faacDecGetCurrentConfiguration (faad->handle);
|
|
|
|
conf->defObjectType = LC;
|
2007-04-20 15:31:32 +00:00
|
|
|
conf->dontUpSampleImplicitSBR = 1;
|
ext/faad/gstfaad.*: If we run into a decoding error, try re-opening the decoder with faacDecInit2() using fake codec ...
Original commit message from CVS:
* ext/faad/gstfaad.c: (gst_faad_init), (aac_rate_idx),
(gst_faad_setcaps), (gst_faad_chain), (gst_faad_open_decoder),
(gst_faad_close_decoder), (gst_faad_change_state):
* ext/faad/gstfaad.h:
If we run into a decoding error, try re-opening the decoder
with faacDecInit2() using fake codec data created from the
data the demuxer gave us. Should fix a whole bunch of
GStreamer-faad problems incl. 'channel coupling not
implemented', 'maximum number of scalefactor bands exceeded'
etc. (#173007, #332892).
2006-04-28 11:04:12 +00:00
|
|
|
conf->outputFormat = FAAD_FMT_16BIT;
|
|
|
|
|
|
|
|
if (faacDecSetConfiguration (faad->handle, conf) == 0) {
|
|
|
|
GST_WARNING_OBJECT (faad, "faacDecSetConfiguration() failed");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_faad_close_decoder (GstFaad * faad)
|
|
|
|
{
|
2006-10-06 15:49:39 +00:00
|
|
|
if (faad->handle) {
|
|
|
|
faacDecClose (faad->handle);
|
|
|
|
faad->handle = NULL;
|
|
|
|
}
|
2003-11-21 21:20:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2003-11-21 21:20:42 +00:00
|
|
|
{
|
2021-02-17 14:59:49 +00:00
|
|
|
return GST_ELEMENT_REGISTER (faad, plugin);
|
2003-11-21 21:20:42 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
2012-04-05 16:02:56 +00:00
|
|
|
faad,
|
2004-03-14 22:34:33 +00:00
|
|
|
"Free AAC Decoder (FAAD)",
|
2006-04-01 10:09:11 +00:00
|
|
|
plugin_init, VERSION, "GPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|