2003-04-14 01:20:30 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
2005-08-24 13:32:52 +00:00
|
|
|
* Copyright (C) 2005 Thomas Vander Stichele <thomas at apestaart dot org>
|
2011-08-18 17:15:03 +00:00
|
|
|
* Copyright (C) 2011 Wim Taymans <wim.taymans at gmail dot com>
|
2003-04-14 01:20:30 +00:00
|
|
|
*
|
|
|
|
* gstaudioconvert.c: Convert audio to different audio formats automatically
|
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2005-09-23 14:41:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* SECTION:element-audioconvert
|
|
|
|
*
|
|
|
|
* Audioconvert converts raw audio buffers between various possible formats.
|
2005-11-08 12:18:14 +00:00
|
|
|
* It supports integer to float conversion, width/depth conversion,
|
2008-07-10 21:06:06 +00:00
|
|
|
* signedness and endianness conversion and channel transformations.
|
|
|
|
*
|
|
|
|
* <refsect2>
|
2005-09-23 14:41:31 +00:00
|
|
|
* <title>Example launch line</title>
|
2008-07-10 21:06:06 +00:00
|
|
|
* |[
|
2011-08-18 17:15:03 +00:00
|
|
|
* gst-launch -v -m audiotestsrc ! audioconvert ! audio/x-raw,format=S8,channels=2 ! level ! fakesink silent=TRUE
|
2008-07-10 21:06:06 +00:00
|
|
|
* ]| This pipeline converts audio to 8-bit. The level element shows that
|
2005-09-23 14:41:31 +00:00
|
|
|
* the output levels still match the one for a sine wave.
|
2008-07-10 21:06:06 +00:00
|
|
|
* |[
|
2005-11-23 15:36:58 +00:00
|
|
|
* gst-launch -v -m audiotestsrc ! audioconvert ! vorbisenc ! fakesink silent=TRUE
|
2008-07-10 21:06:06 +00:00
|
|
|
* ]| The vorbis encoder takes float audio data instead of the integer data
|
2005-11-23 15:36:58 +00:00
|
|
|
* generated by audiotestsrc.
|
2005-09-23 14:41:31 +00:00
|
|
|
* </refsect2>
|
docs/plugins/: Add audioresample to docs.
Original commit message from CVS:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-base-plugins-docs.sgml:
* docs/plugins/gst-plugins-base-plugins-sections.txt:
Add audioresample to docs.
* gst/audioconvert/gstaudioconvert.c:
Add revision date.
* gst/audioresample/gstaudioresample.c:
(gst_audioresample_base_init), (gst_audioresample_class_init),
(gst_audioresample_init), (gst_audioresample_dispose),
(audioresample_get_unit_size), (audioresample_transform_caps),
(resample_set_state_from_caps), (audioresample_transform_size),
(audioresample_set_caps), (audioresample_event),
(audioresample_do_output), (audioresample_transform),
(audioresample_pushthrough), (gst_audioresample_set_property),
(gst_audioresample_get_property), (plugin_init):
* gst/audioresample/gstaudioresample.h:
Added docs.
Small code cleanups.
2006-03-02 18:23:55 +00:00
|
|
|
*
|
|
|
|
* Last reviewed on 2006-03-02 (0.10.4)
|
2005-09-23 14:41:31 +00:00
|
|
|
*/
|
2003-04-14 01:20:30 +00:00
|
|
|
|
2004-03-06 15:31:25 +00:00
|
|
|
/*
|
|
|
|
* design decisions:
|
2005-08-24 13:32:52 +00:00
|
|
|
* - audioconvert converts buffers in a set of supported caps. If it supports
|
|
|
|
* a caps, it supports conversion from these caps to any other caps it
|
2004-03-06 15:31:25 +00:00
|
|
|
* supports. (example: if it does A=>B and A=>C, it also does B=>C)
|
|
|
|
* - audioconvert does not save state between buffers. Every incoming buffer is
|
|
|
|
* converted and the converted buffer is pushed out.
|
|
|
|
* conclusion:
|
|
|
|
* audioconvert is not supposed to be a one-element-does-anything solution for
|
|
|
|
* audio conversions.
|
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
2004-02-25 18:02:19 +00:00
|
|
|
#include "config.h"
|
2003-06-29 19:46:12 +00:00
|
|
|
#endif
|
2003-07-19 22:58:41 +00:00
|
|
|
|
2003-04-14 01:20:30 +00:00
|
|
|
#include <string.h>
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
|
|
|
|
#include "gstaudioconvert.h"
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
#include "gstchannelmix.h"
|
gst/audioconvert/: Implement dithering and noise shaping in audioconvert. By default now
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (audio_convert_get_func_index),
(check_default), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_dithering_get_type),
(gst_audio_convert_ns_get_type), (gst_audio_convert_class_init),
(gst_audio_convert_init), (gst_audio_convert_set_caps),
(gst_audio_convert_set_property), (gst_audio_convert_get_property):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstaudioquantize.c:
(gst_audio_quantize_setup_noise_shaping),
(gst_audio_quantize_free_noise_shaping),
(gst_audio_quantize_setup_dither),
(gst_audio_quantize_free_dither),
(gst_audio_quantize_setup_quantize_func),
(gst_audio_quantize_setup), (gst_audio_quantize_free):
* gst/audioconvert/gstaudioquantize.h:
Implement dithering and noise shaping in audioconvert. By default now
TPDF dithering (and no noise shaping) will be used when converting
from a higher bit depth to 20 bit depth or smaller, otherwise
everything will be as it is now.
For the last audioconvert in a pipeline it would make sense to
use some kind of noise shaping, enabling it by default for all
conversions would give undesired results though. Fixes #360246.
* tests/check/elements/audioconvert.c: (setup_audioconvert),
(GST_START_TEST):
Adjust unit test for the new audioconvert.
2007-06-28 20:37:58 +00:00
|
|
|
#include "gstaudioquantize.h"
|
2004-04-09 12:39:30 +00:00
|
|
|
#include "plugin.h"
|
2003-04-14 01:20:30 +00:00
|
|
|
|
gst/audioconvert/: Implement a channel mixer.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_init),
(gst_audio_convert_link), (gst_audio_convert_change_state),
(gst_audio_convert_channels):
* gst/audioconvert/gstchannelmix.c:
(gst_audio_convert_unset_matrix),
(gst_audio_convert_fill_identical),
(gst_audio_convert_fill_compatible),
(gst_audio_convert_detect_pos), (gst_audio_convert_fill_one_other),
(gst_audio_convert_fill_others),
(gst_audio_convert_fill_normalize),
(gst_audio_convert_fill_matrix), (gst_audio_convert_setup_matrix),
(gst_audio_convert_passthrough), (gst_audio_convert_mix):
* gst/audioconvert/gstchannelmix.h:
Implement a channel mixer.
2004-11-28 16:09:13 +00:00
|
|
|
GST_DEBUG_CATEGORY (audio_convert_debug);
|
2009-10-12 18:30:15 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (GST_CAT_PERFORMANCE);
|
2004-01-12 19:46:45 +00:00
|
|
|
|
2003-04-14 01:20:30 +00:00
|
|
|
/*** DEFINITIONS **************************************************************/
|
|
|
|
|
|
|
|
/* type functions */
|
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
|
|
|
static void gst_audio_convert_dispose (GObject * obj);
|
2003-07-19 22:58:41 +00:00
|
|
|
|
|
|
|
/* gstreamer functions */
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
static gboolean gst_audio_convert_get_unit_size (GstBaseTransform * base,
|
2011-03-27 14:35:28 +00:00
|
|
|
GstCaps * caps, gsize * size);
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
static GstCaps *gst_audio_convert_transform_caps (GstBaseTransform * base,
|
2011-05-16 08:56:11 +00:00
|
|
|
GstPadDirection direction, GstCaps * caps, GstCaps * filter);
|
2012-02-22 11:27:49 +00:00
|
|
|
static GstCaps *gst_audio_convert_fixate_caps (GstBaseTransform * base,
|
2005-08-24 13:32:52 +00:00
|
|
|
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
static gboolean gst_audio_convert_set_caps (GstBaseTransform * base,
|
|
|
|
GstCaps * incaps, GstCaps * outcaps);
|
|
|
|
static GstFlowReturn gst_audio_convert_transform (GstBaseTransform * base,
|
|
|
|
GstBuffer * inbuf, GstBuffer * outbuf);
|
gst/audioconvert/: Implement dithering and noise shaping in audioconvert. By default now
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (audio_convert_get_func_index),
(check_default), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_dithering_get_type),
(gst_audio_convert_ns_get_type), (gst_audio_convert_class_init),
(gst_audio_convert_init), (gst_audio_convert_set_caps),
(gst_audio_convert_set_property), (gst_audio_convert_get_property):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstaudioquantize.c:
(gst_audio_quantize_setup_noise_shaping),
(gst_audio_quantize_free_noise_shaping),
(gst_audio_quantize_setup_dither),
(gst_audio_quantize_free_dither),
(gst_audio_quantize_setup_quantize_func),
(gst_audio_quantize_setup), (gst_audio_quantize_free):
* gst/audioconvert/gstaudioquantize.h:
Implement dithering and noise shaping in audioconvert. By default now
TPDF dithering (and no noise shaping) will be used when converting
from a higher bit depth to 20 bit depth or smaller, otherwise
everything will be as it is now.
For the last audioconvert in a pipeline it would make sense to
use some kind of noise shaping, enabling it by default for all
conversions would give undesired results though. Fixes #360246.
* tests/check/elements/audioconvert.c: (setup_audioconvert),
(GST_START_TEST):
Adjust unit test for the new audioconvert.
2007-06-28 20:37:58 +00:00
|
|
|
static void gst_audio_convert_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_audio_convert_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec);
|
2005-08-24 13:32:52 +00:00
|
|
|
|
2003-04-14 01:20:30 +00:00
|
|
|
/* AudioConvert signals and args */
|
2004-03-14 22:34:34 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-04-14 01:20:30 +00:00
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
2003-07-19 22:58:41 +00:00
|
|
|
|
2004-03-14 22:34:34 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-04-14 01:20:30 +00:00
|
|
|
ARG_0,
|
gst/audioconvert/: Implement dithering and noise shaping in audioconvert. By default now
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (audio_convert_get_func_index),
(check_default), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_dithering_get_type),
(gst_audio_convert_ns_get_type), (gst_audio_convert_class_init),
(gst_audio_convert_init), (gst_audio_convert_set_caps),
(gst_audio_convert_set_property), (gst_audio_convert_get_property):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstaudioquantize.c:
(gst_audio_quantize_setup_noise_shaping),
(gst_audio_quantize_free_noise_shaping),
(gst_audio_quantize_setup_dither),
(gst_audio_quantize_free_dither),
(gst_audio_quantize_setup_quantize_func),
(gst_audio_quantize_setup), (gst_audio_quantize_free):
* gst/audioconvert/gstaudioquantize.h:
Implement dithering and noise shaping in audioconvert. By default now
TPDF dithering (and no noise shaping) will be used when converting
from a higher bit depth to 20 bit depth or smaller, otherwise
everything will be as it is now.
For the last audioconvert in a pipeline it would make sense to
use some kind of noise shaping, enabling it by default for all
conversions would give undesired results though. Fixes #360246.
* tests/check/elements/audioconvert.c: (setup_audioconvert),
(GST_START_TEST):
Adjust unit test for the new audioconvert.
2007-06-28 20:37:58 +00:00
|
|
|
ARG_DITHERING,
|
|
|
|
ARG_NOISE_SHAPING,
|
2003-04-14 01:20:30 +00:00
|
|
|
};
|
|
|
|
|
2011-04-19 09:35:53 +00:00
|
|
|
#define DEBUG_INIT \
|
2009-10-12 18:30:15 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (audio_convert_debug, "audioconvert", 0, "audio conversion element"); \
|
|
|
|
GST_DEBUG_CATEGORY_GET (GST_CAT_PERFORMANCE, "GST_PERFORMANCE");
|
2011-04-19 09:35:53 +00:00
|
|
|
#define gst_audio_convert_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstAudioConvert, gst_audio_convert,
|
2005-08-24 13:32:52 +00:00
|
|
|
GST_TYPE_BASE_TRANSFORM, DEBUG_INIT);
|
2003-07-19 22:58:41 +00:00
|
|
|
|
2003-04-14 01:20:30 +00:00
|
|
|
/*** GSTREAMER PROTOTYPES *****************************************************/
|
|
|
|
|
2004-03-06 13:26:12 +00:00
|
|
|
#define STATIC_CAPS \
|
2011-12-31 13:21:27 +00:00
|
|
|
GST_STATIC_CAPS (GST_AUDIO_CAPS_MAKE (GST_AUDIO_FORMATS_ALL) \
|
|
|
|
", layout = (string) interleaved")
|
2004-03-06 13:26:12 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticPadTemplate gst_audio_convert_src_template =
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
STATIC_CAPS);
|
2003-07-19 22:58:41 +00:00
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticPadTemplate gst_audio_convert_sink_template =
|
2004-03-14 22:34:34 +00:00
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
STATIC_CAPS);
|
2003-04-14 01:20:30 +00:00
|
|
|
|
gst/audioconvert/: Implement dithering and noise shaping in audioconvert. By default now
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (audio_convert_get_func_index),
(check_default), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_dithering_get_type),
(gst_audio_convert_ns_get_type), (gst_audio_convert_class_init),
(gst_audio_convert_init), (gst_audio_convert_set_caps),
(gst_audio_convert_set_property), (gst_audio_convert_get_property):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstaudioquantize.c:
(gst_audio_quantize_setup_noise_shaping),
(gst_audio_quantize_free_noise_shaping),
(gst_audio_quantize_setup_dither),
(gst_audio_quantize_free_dither),
(gst_audio_quantize_setup_quantize_func),
(gst_audio_quantize_setup), (gst_audio_quantize_free):
* gst/audioconvert/gstaudioquantize.h:
Implement dithering and noise shaping in audioconvert. By default now
TPDF dithering (and no noise shaping) will be used when converting
from a higher bit depth to 20 bit depth or smaller, otherwise
everything will be as it is now.
For the last audioconvert in a pipeline it would make sense to
use some kind of noise shaping, enabling it by default for all
conversions would give undesired results though. Fixes #360246.
* tests/check/elements/audioconvert.c: (setup_audioconvert),
(GST_START_TEST):
Adjust unit test for the new audioconvert.
2007-06-28 20:37:58 +00:00
|
|
|
#define GST_TYPE_AUDIO_CONVERT_DITHERING (gst_audio_convert_dithering_get_type ())
|
|
|
|
static GType
|
|
|
|
gst_audio_convert_dithering_get_type (void)
|
|
|
|
{
|
|
|
|
static GType gtype = 0;
|
|
|
|
|
|
|
|
if (gtype == 0) {
|
|
|
|
static const GEnumValue values[] = {
|
|
|
|
{DITHER_NONE, "No dithering",
|
|
|
|
"none"},
|
|
|
|
{DITHER_RPDF, "Rectangular dithering", "rpdf"},
|
|
|
|
{DITHER_TPDF, "Triangular dithering (default)", "tpdf"},
|
|
|
|
{DITHER_TPDF_HF, "High frequency triangular dithering", "tpdf-hf"},
|
|
|
|
{0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
gtype = g_enum_register_static ("GstAudioConvertDithering", values);
|
|
|
|
}
|
|
|
|
return gtype;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define GST_TYPE_AUDIO_CONVERT_NOISE_SHAPING (gst_audio_convert_ns_get_type ())
|
|
|
|
static GType
|
|
|
|
gst_audio_convert_ns_get_type (void)
|
|
|
|
{
|
|
|
|
static GType gtype = 0;
|
|
|
|
|
|
|
|
if (gtype == 0) {
|
|
|
|
static const GEnumValue values[] = {
|
|
|
|
{NOISE_SHAPING_NONE, "No noise shaping (default)",
|
|
|
|
"none"},
|
|
|
|
{NOISE_SHAPING_ERROR_FEEDBACK, "Error feedback", "error-feedback"},
|
|
|
|
{NOISE_SHAPING_SIMPLE, "Simple 2-pole noise shaping", "simple"},
|
|
|
|
{NOISE_SHAPING_MEDIUM, "Medium 5-pole noise shaping", "medium"},
|
|
|
|
{NOISE_SHAPING_HIGH, "High 8-pole noise shaping", "high"},
|
|
|
|
{0, NULL, NULL}
|
|
|
|
};
|
|
|
|
|
|
|
|
gtype = g_enum_register_static ("GstAudioConvertNoiseShaping", values);
|
|
|
|
}
|
|
|
|
return gtype;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-04-14 01:20:30 +00:00
|
|
|
/*** TYPE FUNCTIONS ***********************************************************/
|
|
|
|
static void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_audio_convert_class_init (GstAudioConvertClass * klass)
|
2003-04-14 01:20:30 +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
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
2011-04-19 09:35:53 +00:00
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
2007-02-28 11:47:45 +00:00
|
|
|
GstBaseTransformClass *basetransform_class = GST_BASE_TRANSFORM_CLASS (klass);
|
2003-04-14 01:20:30 +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
|
|
|
gobject_class->dispose = gst_audio_convert_dispose;
|
gst/audioconvert/: Implement dithering and noise shaping in audioconvert. By default now
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (audio_convert_get_func_index),
(check_default), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_dithering_get_type),
(gst_audio_convert_ns_get_type), (gst_audio_convert_class_init),
(gst_audio_convert_init), (gst_audio_convert_set_caps),
(gst_audio_convert_set_property), (gst_audio_convert_get_property):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstaudioquantize.c:
(gst_audio_quantize_setup_noise_shaping),
(gst_audio_quantize_free_noise_shaping),
(gst_audio_quantize_setup_dither),
(gst_audio_quantize_free_dither),
(gst_audio_quantize_setup_quantize_func),
(gst_audio_quantize_setup), (gst_audio_quantize_free):
* gst/audioconvert/gstaudioquantize.h:
Implement dithering and noise shaping in audioconvert. By default now
TPDF dithering (and no noise shaping) will be used when converting
from a higher bit depth to 20 bit depth or smaller, otherwise
everything will be as it is now.
For the last audioconvert in a pipeline it would make sense to
use some kind of noise shaping, enabling it by default for all
conversions would give undesired results though. Fixes #360246.
* tests/check/elements/audioconvert.c: (setup_audioconvert),
(GST_START_TEST):
Adjust unit test for the new audioconvert.
2007-06-28 20:37:58 +00:00
|
|
|
gobject_class->set_property = gst_audio_convert_set_property;
|
|
|
|
gobject_class->get_property = gst_audio_convert_get_property;
|
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/audioconvert/: Implement dithering and noise shaping in audioconvert. By default now
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (audio_convert_get_func_index),
(check_default), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_dithering_get_type),
(gst_audio_convert_ns_get_type), (gst_audio_convert_class_init),
(gst_audio_convert_init), (gst_audio_convert_set_caps),
(gst_audio_convert_set_property), (gst_audio_convert_get_property):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstaudioquantize.c:
(gst_audio_quantize_setup_noise_shaping),
(gst_audio_quantize_free_noise_shaping),
(gst_audio_quantize_setup_dither),
(gst_audio_quantize_free_dither),
(gst_audio_quantize_setup_quantize_func),
(gst_audio_quantize_setup), (gst_audio_quantize_free):
* gst/audioconvert/gstaudioquantize.h:
Implement dithering and noise shaping in audioconvert. By default now
TPDF dithering (and no noise shaping) will be used when converting
from a higher bit depth to 20 bit depth or smaller, otherwise
everything will be as it is now.
For the last audioconvert in a pipeline it would make sense to
use some kind of noise shaping, enabling it by default for all
conversions would give undesired results though. Fixes #360246.
* tests/check/elements/audioconvert.c: (setup_audioconvert),
(GST_START_TEST):
Adjust unit test for the new audioconvert.
2007-06-28 20:37:58 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_DITHERING,
|
|
|
|
g_param_spec_enum ("dithering", "Dithering",
|
|
|
|
"Selects between different dithering methods.",
|
2008-03-22 15:00:53 +00:00
|
|
|
GST_TYPE_AUDIO_CONVERT_DITHERING, DITHER_TPDF,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
gst/audioconvert/: Implement dithering and noise shaping in audioconvert. By default now
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (audio_convert_get_func_index),
(check_default), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_dithering_get_type),
(gst_audio_convert_ns_get_type), (gst_audio_convert_class_init),
(gst_audio_convert_init), (gst_audio_convert_set_caps),
(gst_audio_convert_set_property), (gst_audio_convert_get_property):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstaudioquantize.c:
(gst_audio_quantize_setup_noise_shaping),
(gst_audio_quantize_free_noise_shaping),
(gst_audio_quantize_setup_dither),
(gst_audio_quantize_free_dither),
(gst_audio_quantize_setup_quantize_func),
(gst_audio_quantize_setup), (gst_audio_quantize_free):
* gst/audioconvert/gstaudioquantize.h:
Implement dithering and noise shaping in audioconvert. By default now
TPDF dithering (and no noise shaping) will be used when converting
from a higher bit depth to 20 bit depth or smaller, otherwise
everything will be as it is now.
For the last audioconvert in a pipeline it would make sense to
use some kind of noise shaping, enabling it by default for all
conversions would give undesired results though. Fixes #360246.
* tests/check/elements/audioconvert.c: (setup_audioconvert),
(GST_START_TEST):
Adjust unit test for the new audioconvert.
2007-06-28 20:37:58 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class, ARG_NOISE_SHAPING,
|
|
|
|
g_param_spec_enum ("noise-shaping", "Noise shaping",
|
|
|
|
"Selects between different noise shaping methods.",
|
|
|
|
GST_TYPE_AUDIO_CONVERT_NOISE_SHAPING, NOISE_SHAPING_NONE,
|
2008-03-22 15:00:53 +00:00
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
gst/audioconvert/: Implement dithering and noise shaping in audioconvert. By default now
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (audio_convert_get_func_index),
(check_default), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_dithering_get_type),
(gst_audio_convert_ns_get_type), (gst_audio_convert_class_init),
(gst_audio_convert_init), (gst_audio_convert_set_caps),
(gst_audio_convert_set_property), (gst_audio_convert_get_property):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstaudioquantize.c:
(gst_audio_quantize_setup_noise_shaping),
(gst_audio_quantize_free_noise_shaping),
(gst_audio_quantize_setup_dither),
(gst_audio_quantize_free_dither),
(gst_audio_quantize_setup_quantize_func),
(gst_audio_quantize_setup), (gst_audio_quantize_free):
* gst/audioconvert/gstaudioquantize.h:
Implement dithering and noise shaping in audioconvert. By default now
TPDF dithering (and no noise shaping) will be used when converting
from a higher bit depth to 20 bit depth or smaller, otherwise
everything will be as it is now.
For the last audioconvert in a pipeline it would make sense to
use some kind of noise shaping, enabling it by default for all
conversions would give undesired results though. Fixes #360246.
* tests/check/elements/audioconvert.c: (setup_audioconvert),
(GST_START_TEST):
Adjust unit test for the new audioconvert.
2007-06-28 20:37:58 +00:00
|
|
|
|
2011-04-19 09:35:53 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&gst_audio_convert_src_template));
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&gst_audio_convert_sink_template));
|
2012-04-09 23:45:16 +00:00
|
|
|
gst_element_class_set_static_metadata (element_class,
|
2011-04-19 09:35:53 +00:00
|
|
|
"Audio converter", "Filter/Converter/Audio",
|
|
|
|
"Convert audio to different formats", "Benjamin Otte <otte@gnome.org>");
|
|
|
|
|
2007-02-28 11:47:45 +00:00
|
|
|
basetransform_class->get_unit_size =
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_audio_convert_get_unit_size);
|
2007-02-28 11:47:45 +00:00
|
|
|
basetransform_class->transform_caps =
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_audio_convert_transform_caps);
|
2007-02-28 11:47:45 +00:00
|
|
|
basetransform_class->fixate_caps =
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_audio_convert_fixate_caps);
|
2007-02-28 11:47:45 +00:00
|
|
|
basetransform_class->set_caps =
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_audio_convert_set_caps);
|
2007-02-28 11:47:45 +00:00
|
|
|
basetransform_class->transform =
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_audio_convert_transform);
|
check/: Add extra tests for basetransform based components.
Original commit message from CVS:
* check/Makefile.am:
* check/pipelines/simple_launch_lines.c: (setup_pipeline),
(run_pipeline), (GST_START_TEST), (simple_launch_lines_suite):
Add extra tests for basetransform based components.
Comment out the test_element_negotiation test until we decide
if it's testing correct behaviour.
* ext/libvisual/visual.c: (gst_visual_init), (get_buffer),
(gst_visual_chain), (gst_visual_change_state):
Slightly more correct but still bogus timestamping.
Fix state change function.
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init):
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/gstffmpegcolorspace.c:
(gst_ffmpegcsp_class_init):
* gst/videoscale/gstvideoscale.c: (gst_videoscale_class_init),
(gst_videoscale_prepare_size), (gst_videoscale_set_caps),
(gst_videoscale_prepare_image):
* gst/volume/gstvolume.c: (gst_volume_class_init),
(volume_transform_ip):
Basetransform updates. Enable passthrough modes.
* sys/ximage/ximagesink.c: (gst_ximage_buffer_init),
(gst_ximagesink_renegotiate_size), (gst_ximagesink_xcontext_get),
(gst_ximagesink_setcaps), (gst_ximagesink_buffer_alloc):
Negotiation fix that allows the window to return to the original
size and renegotiate passthrough upstream. Extra debug output.
2005-09-09 17:53:47 +00:00
|
|
|
|
2007-02-28 11:47:45 +00:00
|
|
|
basetransform_class->passthrough_on_same_caps = TRUE;
|
2004-01-12 19:46:45 +00:00
|
|
|
}
|
|
|
|
|
2003-04-14 01:20:30 +00:00
|
|
|
static void
|
2011-04-19 09:35:53 +00:00
|
|
|
gst_audio_convert_init (GstAudioConvert * this)
|
2003-04-14 01:20:30 +00:00
|
|
|
{
|
gst/audioconvert/: Implement dithering and noise shaping in audioconvert. By default now
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (audio_convert_get_func_index),
(check_default), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_dithering_get_type),
(gst_audio_convert_ns_get_type), (gst_audio_convert_class_init),
(gst_audio_convert_init), (gst_audio_convert_set_caps),
(gst_audio_convert_set_property), (gst_audio_convert_get_property):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstaudioquantize.c:
(gst_audio_quantize_setup_noise_shaping),
(gst_audio_quantize_free_noise_shaping),
(gst_audio_quantize_setup_dither),
(gst_audio_quantize_free_dither),
(gst_audio_quantize_setup_quantize_func),
(gst_audio_quantize_setup), (gst_audio_quantize_free):
* gst/audioconvert/gstaudioquantize.h:
Implement dithering and noise shaping in audioconvert. By default now
TPDF dithering (and no noise shaping) will be used when converting
from a higher bit depth to 20 bit depth or smaller, otherwise
everything will be as it is now.
For the last audioconvert in a pipeline it would make sense to
use some kind of noise shaping, enabling it by default for all
conversions would give undesired results though. Fixes #360246.
* tests/check/elements/audioconvert.c: (setup_audioconvert),
(GST_START_TEST):
Adjust unit test for the new audioconvert.
2007-06-28 20:37:58 +00:00
|
|
|
this->dither = DITHER_TPDF;
|
|
|
|
this->ns = NOISE_SHAPING_NONE;
|
2007-04-24 18:58:25 +00:00
|
|
|
memset (&this->ctx, 0, sizeof (AudioConvertCtx));
|
2008-03-21 15:58:44 +00:00
|
|
|
|
|
|
|
gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM (this), 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
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_audio_convert_dispose (GObject * obj)
|
|
|
|
{
|
|
|
|
GstAudioConvert *this = GST_AUDIO_CONVERT (obj);
|
|
|
|
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
audio_convert_clean_context (&this->ctx);
|
2005-08-25 17:32:34 +00:00
|
|
|
|
2004-11-27 14:41:51 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (obj);
|
2003-04-14 01:20:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** GSTREAMER FUNCTIONS ******************************************************/
|
|
|
|
|
2005-08-24 13:32:52 +00:00
|
|
|
/* BaseTransform vmethods */
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
static gboolean
|
|
|
|
gst_audio_convert_get_unit_size (GstBaseTransform * base, GstCaps * caps,
|
2011-03-27 14:35:28 +00:00
|
|
|
gsize * size)
|
2003-04-14 01:20:30 +00:00
|
|
|
{
|
2011-08-18 17:15:03 +00:00
|
|
|
GstAudioInfo info;
|
2003-04-14 01:20:30 +00:00
|
|
|
|
2006-08-20 13:05:44 +00:00
|
|
|
g_assert (size);
|
2003-04-14 01:20:30 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
if (!gst_audio_info_from_caps (&info, caps))
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
goto parse_error;
|
2005-05-23 17:28:02 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
*size = info.bpf;
|
|
|
|
GST_INFO_OBJECT (base, "unit_size = %" G_GSIZE_FORMAT, *size);
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
|
2005-08-24 13:32:52 +00:00
|
|
|
return TRUE;
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
|
|
|
|
parse_error:
|
|
|
|
{
|
2007-02-28 11:47:45 +00:00
|
|
|
GST_INFO_OBJECT (base, "failed to parse caps to get unit_size");
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2005-08-24 13:32:52 +00:00
|
|
|
}
|
gst/: Don't ignore _push() return values.
Original commit message from CVS:
* gst/audioconvert/gstaudioconvert.c: (gst_audio_convert_chain),
(gst_audio_convert_caps_remove_format_info),
(gst_audio_convert_setcaps), (gst_audio_convert_fixate),
(gst_audio_convert_change_state), (gst_audio_convert_channels):
* gst/videotestsrc/gstvideotestsrc.c:
(gst_videotestsrc_src_negotiate), (gst_videotestsrc_src_link),
(gst_videotestsrc_parse_caps), (gst_videotestsrc_src_accept_caps),
(gst_videotestsrc_setcaps), (gst_videotestsrc_activate),
(gst_videotestsrc_init), (gst_videotestsrc_loop):
Don't ignore _push() return values.
Make sure no processing is done when shutting down.
Videotestsrc pad activation fix.
2005-05-05 09:49:08 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
/* copies the given caps */
|
|
|
|
static GstCaps *
|
2012-07-25 12:55:56 +00:00
|
|
|
gst_audio_convert_caps_remove_format_info (GstCaps * caps, gboolean channels)
|
2007-03-16 17:29:09 +00:00
|
|
|
{
|
2011-08-18 17:15:03 +00:00
|
|
|
GstStructure *st;
|
|
|
|
gint i, n;
|
|
|
|
GstCaps *res;
|
2011-12-19 11:41:24 +00:00
|
|
|
guint64 channel_mask;
|
2007-03-16 17:29:09 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
res = gst_caps_new_empty ();
|
2007-03-16 17:29:09 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
n = gst_caps_get_size (caps);
|
|
|
|
for (i = 0; i < n; i++) {
|
2012-07-25 12:55:56 +00:00
|
|
|
gboolean remove_channels = FALSE;
|
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
st = gst_caps_get_structure (caps, i);
|
2008-05-06 12:12:16 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
/* If this is already expressed by the existing caps
|
|
|
|
* skip this structure */
|
|
|
|
if (i > 0 && gst_caps_is_subset_structure (res, st))
|
|
|
|
continue;
|
2008-05-06 12:12:16 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
st = gst_structure_copy (st);
|
2011-12-19 11:41:24 +00:00
|
|
|
gst_structure_remove_field (st, "format");
|
|
|
|
|
|
|
|
/* Only remove the channels and channel-mask for non-NONE layouts */
|
|
|
|
if (gst_structure_get (st, "channel-mask", GST_TYPE_BITMASK, &channel_mask,
|
|
|
|
NULL)) {
|
|
|
|
if (channel_mask != 0)
|
2012-07-25 12:55:56 +00:00
|
|
|
remove_channels = TRUE;
|
2011-12-19 11:41:24 +00:00
|
|
|
} else {
|
2012-07-25 12:55:56 +00:00
|
|
|
remove_channels = TRUE;
|
2011-12-19 11:41:24 +00:00
|
|
|
}
|
2008-05-06 12:12:16 +00:00
|
|
|
|
2012-07-25 12:55:56 +00:00
|
|
|
if (remove_channels && channels)
|
|
|
|
gst_structure_remove_fields (st, "channel-mask", "channels", NULL);
|
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
gst_caps_append_structure (res, st);
|
2008-05-06 12:12:16 +00:00
|
|
|
}
|
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
return res;
|
2008-05-06 12:12:16 +00:00
|
|
|
}
|
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
/* The caps can be transformed into any other caps with format info removed.
|
|
|
|
* However, we should prefer passthrough, so if passthrough is possible,
|
|
|
|
* put it first in the list. */
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
static GstCaps *
|
2011-08-18 17:15:03 +00:00
|
|
|
gst_audio_convert_transform_caps (GstBaseTransform * btrans,
|
2011-05-16 08:56:11 +00:00
|
|
|
GstPadDirection direction, GstCaps * caps, GstCaps * filter)
|
2005-08-24 13:32:52 +00:00
|
|
|
{
|
2011-08-18 17:15:03 +00:00
|
|
|
GstCaps *tmp, *tmp2;
|
|
|
|
GstCaps *result;
|
2006-05-29 11:04:48 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
/* Get all possible caps that we can transform to */
|
2012-07-25 12:55:56 +00:00
|
|
|
tmp = gst_audio_convert_caps_remove_format_info (caps, TRUE);
|
2006-05-29 11:04:48 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
if (filter) {
|
|
|
|
tmp2 = gst_caps_intersect_full (filter, tmp, GST_CAPS_INTERSECT_FIRST);
|
|
|
|
gst_caps_unref (tmp);
|
|
|
|
tmp = tmp2;
|
2011-05-27 10:13:14 +00:00
|
|
|
}
|
2006-05-29 11:04:48 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
result = tmp;
|
2007-03-16 16:42:23 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
GST_DEBUG_OBJECT (btrans, "transformed %" GST_PTR_FORMAT " into %"
|
|
|
|
GST_PTR_FORMAT, caps, result);
|
2011-05-16 08:56:11 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
return result;
|
2003-04-14 01:20:30 +00:00
|
|
|
}
|
2003-07-19 22:58:41 +00:00
|
|
|
|
2007-10-31 17:54:48 +00:00
|
|
|
static const GstAudioChannelPosition default_positions[8][8] = {
|
|
|
|
/* 1 channel */
|
|
|
|
{
|
2011-12-19 11:41:24 +00:00
|
|
|
GST_AUDIO_CHANNEL_POSITION_MONO,
|
2007-10-31 17:54:48 +00:00
|
|
|
},
|
|
|
|
/* 2 channels */
|
|
|
|
{
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
|
|
|
},
|
|
|
|
/* 3 channels (2.1) */
|
|
|
|
{
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
2011-12-19 11:41:24 +00:00
|
|
|
GST_AUDIO_CHANNEL_POSITION_LFE1,
|
2007-10-31 17:54:48 +00:00
|
|
|
},
|
2011-12-19 11:41:24 +00:00
|
|
|
/* 4 channels (4.0) */
|
2007-10-31 17:54:48 +00:00
|
|
|
{
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
|
|
|
|
},
|
|
|
|
/* 5 channels */
|
|
|
|
{
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
|
|
|
},
|
2011-12-19 11:41:24 +00:00
|
|
|
/* 6 channels (5.1) */
|
2007-10-31 17:54:48 +00:00
|
|
|
{
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
2011-12-19 11:41:24 +00:00
|
|
|
GST_AUDIO_CHANNEL_POSITION_LFE1,
|
2007-10-31 17:54:48 +00:00
|
|
|
},
|
2011-12-19 11:41:24 +00:00
|
|
|
/* 7 channels (6.1) */
|
2007-10-31 17:54:48 +00:00
|
|
|
{
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
2011-12-19 11:41:24 +00:00
|
|
|
GST_AUDIO_CHANNEL_POSITION_LFE1,
|
2007-10-31 17:54:48 +00:00
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_CENTER,
|
|
|
|
},
|
2011-12-19 11:41:24 +00:00
|
|
|
/* 8 channels (7.1) */
|
2007-10-31 17:54:48 +00:00
|
|
|
{
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_REAR_RIGHT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_FRONT_CENTER,
|
2011-12-19 11:41:24 +00:00
|
|
|
GST_AUDIO_CHANNEL_POSITION_LFE1,
|
2007-10-31 17:54:48 +00:00
|
|
|
GST_AUDIO_CHANNEL_POSITION_SIDE_LEFT,
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_SIDE_RIGHT,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2011-12-19 11:41:24 +00:00
|
|
|
static gint
|
|
|
|
n_bits_set (guint64 x)
|
2007-10-31 17:54:48 +00:00
|
|
|
{
|
2011-12-19 11:41:24 +00:00
|
|
|
gint i;
|
|
|
|
gint c = 0;
|
|
|
|
guint64 y = 1;
|
|
|
|
|
|
|
|
for (i = 0; i < 64; i++) {
|
|
|
|
if (x & y)
|
|
|
|
c++;
|
|
|
|
y <<= 1;
|
|
|
|
}
|
2007-10-31 17:54:48 +00:00
|
|
|
|
2011-12-19 11:41:24 +00:00
|
|
|
return c;
|
|
|
|
}
|
2007-10-31 17:54:48 +00:00
|
|
|
|
2011-12-19 11:41:24 +00:00
|
|
|
static guint64
|
|
|
|
find_suitable_mask (guint64 mask, gint n_chans)
|
|
|
|
{
|
|
|
|
guint64 intersection;
|
|
|
|
gint i;
|
2007-10-31 17:54:48 +00:00
|
|
|
|
2011-12-19 11:41:24 +00:00
|
|
|
i = 0;
|
2007-10-31 17:54:48 +00:00
|
|
|
|
2011-12-19 11:41:24 +00:00
|
|
|
g_assert (n_bits_set (mask) >= n_chans);
|
|
|
|
|
|
|
|
intersection = mask;
|
|
|
|
do {
|
|
|
|
intersection = intersection & ((~G_GUINT64_CONSTANT (0)) >> i);
|
|
|
|
i++;
|
|
|
|
} while (n_bits_set (intersection) > n_chans && i < 64);
|
|
|
|
|
|
|
|
if (i < 64)
|
|
|
|
return intersection;
|
|
|
|
return 0;
|
2007-10-31 17:54:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_audio_convert_fixate_channels (GstBaseTransform * base, GstStructure * ins,
|
|
|
|
GstStructure * outs)
|
|
|
|
{
|
|
|
|
gint in_chans, out_chans;
|
2011-12-19 11:41:24 +00:00
|
|
|
guint64 in_mask = 0, out_mask = 0;
|
|
|
|
gboolean has_in_mask = FALSE, has_out_mask = FALSE;
|
2007-10-31 17:54:48 +00:00
|
|
|
|
|
|
|
if (!gst_structure_get_int (ins, "channels", &in_chans))
|
|
|
|
return; /* this shouldn't really happen, should it? */
|
|
|
|
|
|
|
|
if (!gst_structure_has_field (outs, "channels")) {
|
|
|
|
/* we could try to get the implied number of channels from the layout,
|
|
|
|
* but that seems overdoing it for a somewhat exotic corner case */
|
2011-12-19 11:41:24 +00:00
|
|
|
gst_structure_remove_field (outs, "channel-mask");
|
2007-10-31 17:54:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ok, let's fixate the channels if they are not fixated yet */
|
|
|
|
gst_structure_fixate_field_nearest_int (outs, "channels", in_chans);
|
|
|
|
|
|
|
|
if (!gst_structure_get_int (outs, "channels", &out_chans)) {
|
|
|
|
/* shouldn't really happen ... */
|
2011-12-19 11:41:24 +00:00
|
|
|
gst_structure_remove_field (outs, "channel-mask");
|
2007-10-31 17:54:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-19 11:41:24 +00:00
|
|
|
/* get the channel layout of the output if any */
|
|
|
|
has_out_mask = gst_structure_has_field (outs, "channel-mask");
|
|
|
|
if (has_out_mask) {
|
|
|
|
gst_structure_get (outs, "channel-mask", GST_TYPE_BITMASK, &out_mask, NULL);
|
|
|
|
} else {
|
|
|
|
/* channels == 1 => MONO */
|
|
|
|
if (out_chans == 2) {
|
|
|
|
out_mask =
|
2012-01-04 09:26:33 +00:00
|
|
|
GST_AUDIO_CHANNEL_POSITION_MASK (FRONT_LEFT) |
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_MASK (FRONT_RIGHT);
|
2011-12-19 11:41:24 +00:00
|
|
|
has_out_mask = TRUE;
|
2012-01-04 09:26:33 +00:00
|
|
|
gst_structure_set (outs, "channel-mask", GST_TYPE_BITMASK, out_mask,
|
|
|
|
NULL);
|
2011-12-19 11:41:24 +00:00
|
|
|
}
|
|
|
|
}
|
2007-10-31 17:54:48 +00:00
|
|
|
|
2008-05-20 12:15:34 +00:00
|
|
|
/* get the channel layout of the input if any */
|
2011-12-19 11:41:24 +00:00
|
|
|
has_in_mask = gst_structure_has_field (ins, "channel-mask");
|
|
|
|
if (has_in_mask) {
|
|
|
|
gst_structure_get (ins, "channel-mask", GST_TYPE_BITMASK, &in_mask, NULL);
|
|
|
|
} else {
|
|
|
|
/* channels == 1 => MONO */
|
|
|
|
if (in_chans == 2) {
|
|
|
|
in_mask =
|
2012-01-04 09:26:33 +00:00
|
|
|
GST_AUDIO_CHANNEL_POSITION_MASK (FRONT_LEFT) |
|
|
|
|
GST_AUDIO_CHANNEL_POSITION_MASK (FRONT_RIGHT);
|
2011-12-19 11:41:24 +00:00
|
|
|
has_in_mask = TRUE;
|
|
|
|
} else if (in_chans > 2)
|
|
|
|
g_warning ("%s: Upstream caps contain no channel mask",
|
|
|
|
GST_ELEMENT_NAME (base));
|
2007-10-31 17:54:48 +00:00
|
|
|
}
|
|
|
|
|
2011-12-19 11:41:24 +00:00
|
|
|
if (!has_out_mask && out_chans == 1 && (in_chans != out_chans
|
|
|
|
|| !has_in_mask))
|
|
|
|
return; /* nothing to do, default layout will be assumed */
|
2007-10-31 17:54:48 +00:00
|
|
|
|
2011-12-19 11:41:24 +00:00
|
|
|
if (in_chans == out_chans && (has_in_mask || in_chans == 1)) {
|
2007-10-31 17:54:48 +00:00
|
|
|
/* same number of channels and no output layout: just use input layout */
|
2011-12-19 11:41:24 +00:00
|
|
|
if (!has_out_mask) {
|
|
|
|
/* in_chans == 1 handled above already */
|
|
|
|
gst_structure_set (outs, "channel-mask", GST_TYPE_BITMASK, in_mask, NULL);
|
2007-10-31 17:54:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-12-19 11:41:24 +00:00
|
|
|
/* If both masks are the same we're done, this includes the NONE layout case */
|
|
|
|
if (in_mask == out_mask)
|
2007-10-31 17:54:48 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-19 11:41:24 +00:00
|
|
|
/* if output layout is fixed already and looks sane, we're done */
|
|
|
|
if (n_bits_set (out_mask) == out_chans)
|
2007-10-31 17:54:48 +00:00
|
|
|
return;
|
|
|
|
|
2011-12-19 11:41:24 +00:00
|
|
|
if (n_bits_set (out_mask) < in_chans) {
|
|
|
|
/* Not much we can do here, this shouldn't just happen */
|
|
|
|
g_warning ("%s: Invalid downstream channel-mask with too few bits set",
|
|
|
|
GST_ELEMENT_NAME (base));
|
|
|
|
} else {
|
|
|
|
guint64 intersection;
|
|
|
|
|
|
|
|
/* if the output layout is not fixed, check if the output layout contains
|
|
|
|
* the input layout */
|
|
|
|
intersection = in_mask & out_mask;
|
|
|
|
if (n_bits_set (intersection) >= in_chans) {
|
|
|
|
gst_structure_set (outs, "channel-mask", GST_TYPE_BITMASK, in_mask,
|
|
|
|
NULL);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* output layout is not fixed and does not contain the input layout, so
|
|
|
|
* just pick the first possibility */
|
|
|
|
intersection = find_suitable_mask (out_mask, out_chans);
|
|
|
|
if (intersection) {
|
|
|
|
gst_structure_set (outs, "channel-mask", GST_TYPE_BITMASK, intersection,
|
|
|
|
NULL);
|
|
|
|
return;
|
|
|
|
}
|
2007-10-31 17:54:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ... else fall back to default layout (NB: out_layout is NULL here) */
|
|
|
|
GST_WARNING_OBJECT (base, "unexpected output channel layout");
|
2011-12-19 11:41:24 +00:00
|
|
|
} else {
|
|
|
|
guint64 intersection;
|
|
|
|
|
|
|
|
/* number of input channels != number of output channels:
|
|
|
|
* if this value contains a list of channel layouts (or even worse: a list
|
|
|
|
* with another list), just pick the first value and repeat until we find a
|
|
|
|
* channel position array or something else that's not a list; we assume
|
|
|
|
* the input if half-way sane and don't try to fall back on other list items
|
|
|
|
* if the first one is something unexpected or non-channel-pos-array-y */
|
|
|
|
if (n_bits_set (out_mask) >= out_chans) {
|
|
|
|
intersection = find_suitable_mask (out_mask, out_chans);
|
|
|
|
gst_structure_set (outs, "channel-mask", GST_TYPE_BITMASK, intersection,
|
|
|
|
NULL);
|
2007-10-31 17:54:48 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* what now?! Just ignore what we're given and use default positions */
|
|
|
|
GST_WARNING_OBJECT (base, "invalid or unexpected channel-positions");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* missing or invalid output layout and we can't use the input layout for
|
|
|
|
* one reason or another, so just pick a default layout (we could be smarter
|
|
|
|
* and try to add/remove channels from the input layout, or pick a default
|
|
|
|
* layout based on LFE-presence in input layout, but let's save that for
|
|
|
|
* another day) */
|
2008-05-20 08:12:19 +00:00
|
|
|
if (out_chans > 0 && out_chans <= G_N_ELEMENTS (default_positions[0])) {
|
2011-12-19 11:41:24 +00:00
|
|
|
gint i;
|
|
|
|
|
2007-10-31 17:54:48 +00:00
|
|
|
GST_DEBUG_OBJECT (base, "using default channel layout as fallback");
|
2011-12-19 11:41:24 +00:00
|
|
|
|
|
|
|
out_mask = 0;
|
|
|
|
for (i = 0; i < out_chans; i++)
|
2012-01-04 09:26:33 +00:00
|
|
|
out_mask |= G_GUINT64_CONSTANT (1) << default_positions[out_chans - 1][i];
|
2011-12-19 11:41:24 +00:00
|
|
|
|
|
|
|
gst_structure_set (outs, "channel-mask", GST_TYPE_BITMASK, out_mask, NULL);
|
|
|
|
} else {
|
|
|
|
GST_ERROR_OBJECT (base, "Have no default layout for %d channels",
|
|
|
|
out_chans);
|
2007-10-31 17:54:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-24 13:32:52 +00:00
|
|
|
/* try to keep as many of the structure members the same by fixating the
|
|
|
|
* possible ranges; this way we convert the least amount of things as possible
|
|
|
|
*/
|
2012-02-22 11:27:49 +00:00
|
|
|
static GstCaps *
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
gst_audio_convert_fixate_caps (GstBaseTransform * base,
|
2005-08-24 13:32:52 +00:00
|
|
|
GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
|
2004-01-15 21:05:17 +00:00
|
|
|
{
|
2005-08-24 13:32:52 +00:00
|
|
|
GstStructure *ins, *outs;
|
2012-02-27 11:52:07 +00:00
|
|
|
GstCaps *result;
|
2005-08-24 13:32:52 +00:00
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (base, "trying to fixate othercaps %" GST_PTR_FORMAT
|
|
|
|
" based on caps %" GST_PTR_FORMAT, othercaps, caps);
|
|
|
|
|
2012-02-27 11:52:07 +00:00
|
|
|
result = gst_caps_intersect (othercaps, caps);
|
|
|
|
if (gst_caps_is_empty (result)) {
|
2012-07-25 12:55:56 +00:00
|
|
|
GstCaps *removed;
|
|
|
|
|
2012-03-30 14:56:40 +00:00
|
|
|
if (result)
|
|
|
|
gst_caps_unref (result);
|
2012-07-25 12:55:56 +00:00
|
|
|
/* try to preserve channels */
|
|
|
|
removed = gst_audio_convert_caps_remove_format_info (caps, FALSE);
|
|
|
|
result = gst_caps_intersect (othercaps, removed);
|
|
|
|
gst_caps_unref (removed);
|
|
|
|
if (gst_caps_is_empty (result)) {
|
|
|
|
if (result)
|
|
|
|
gst_caps_unref (result);
|
|
|
|
result = othercaps;
|
2012-09-06 11:58:28 +00:00
|
|
|
} else {
|
|
|
|
gst_caps_unref (othercaps);
|
2012-07-25 12:55:56 +00:00
|
|
|
}
|
2012-02-27 11:52:07 +00:00
|
|
|
} else {
|
|
|
|
gst_caps_unref (othercaps);
|
|
|
|
}
|
2005-08-24 13:32:52 +00:00
|
|
|
|
2012-07-25 12:55:56 +00:00
|
|
|
GST_DEBUG_OBJECT (base, "now fixating %" GST_PTR_FORMAT, result);
|
|
|
|
|
2012-02-27 11:52:07 +00:00
|
|
|
/* fixate remaining fields */
|
|
|
|
result = gst_caps_make_writable (result);
|
2007-10-31 17:54:48 +00:00
|
|
|
|
2012-02-27 11:52:07 +00:00
|
|
|
ins = gst_caps_get_structure (caps, 0);
|
|
|
|
outs = gst_caps_get_structure (result, 0);
|
2011-08-18 17:15:03 +00:00
|
|
|
|
2012-02-27 11:52:07 +00:00
|
|
|
gst_audio_convert_fixate_channels (base, ins, outs);
|
2012-03-11 18:04:41 +00:00
|
|
|
result = gst_caps_fixate (result);
|
2011-11-10 14:24:30 +00:00
|
|
|
|
2012-02-27 11:52:07 +00:00
|
|
|
GST_DEBUG_OBJECT (base, "fixated othercaps to %" GST_PTR_FORMAT, result);
|
2012-02-22 11:27:49 +00:00
|
|
|
|
2012-02-27 11:52:07 +00:00
|
|
|
return result;
|
2005-03-31 09:43:49 +00:00
|
|
|
}
|
|
|
|
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
static gboolean
|
|
|
|
gst_audio_convert_set_caps (GstBaseTransform * base, GstCaps * incaps,
|
2005-08-24 13:32:52 +00:00
|
|
|
GstCaps * outcaps)
|
2005-03-31 09:43:49 +00:00
|
|
|
{
|
2005-08-24 13:32:52 +00:00
|
|
|
GstAudioConvert *this = GST_AUDIO_CONVERT (base);
|
2011-08-18 17:15:03 +00:00
|
|
|
GstAudioInfo in_info;
|
|
|
|
GstAudioInfo out_info;
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2005-08-24 13:32:52 +00:00
|
|
|
GST_DEBUG_OBJECT (base, "incaps %" GST_PTR_FORMAT ", outcaps %"
|
|
|
|
GST_PTR_FORMAT, incaps, outcaps);
|
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
if (!gst_audio_info_from_caps (&in_info, incaps))
|
|
|
|
goto invalid_in;
|
|
|
|
if (!gst_audio_info_from_caps (&out_info, outcaps))
|
|
|
|
goto invalid_out;
|
2005-08-24 13:32:52 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
if (!audio_convert_prepare_context (&this->ctx, &in_info, &out_info,
|
gst/audioconvert/: Implement dithering and noise shaping in audioconvert. By default now
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (audio_convert_get_func_index),
(check_default), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_dithering_get_type),
(gst_audio_convert_ns_get_type), (gst_audio_convert_class_init),
(gst_audio_convert_init), (gst_audio_convert_set_caps),
(gst_audio_convert_set_property), (gst_audio_convert_get_property):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstaudioquantize.c:
(gst_audio_quantize_setup_noise_shaping),
(gst_audio_quantize_free_noise_shaping),
(gst_audio_quantize_setup_dither),
(gst_audio_quantize_free_dither),
(gst_audio_quantize_setup_quantize_func),
(gst_audio_quantize_setup), (gst_audio_quantize_free):
* gst/audioconvert/gstaudioquantize.h:
Implement dithering and noise shaping in audioconvert. By default now
TPDF dithering (and no noise shaping) will be used when converting
from a higher bit depth to 20 bit depth or smaller, otherwise
everything will be as it is now.
For the last audioconvert in a pipeline it would make sense to
use some kind of noise shaping, enabling it by default for all
conversions would give undesired results though. Fixes #360246.
* tests/check/elements/audioconvert.c: (setup_audioconvert),
(GST_START_TEST):
Adjust unit test for the new audioconvert.
2007-06-28 20:37:58 +00:00
|
|
|
this->dither, this->ns))
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
goto no_converter;
|
2005-08-24 13:32:52 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2005-03-31 09:43:49 +00:00
|
|
|
|
2011-08-18 17:15:03 +00:00
|
|
|
/* ERRORS */
|
|
|
|
invalid_in:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (base, "invalid input caps");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
invalid_out:
|
|
|
|
{
|
|
|
|
GST_ERROR_OBJECT (base, "invalid output caps");
|
|
|
|
return FALSE;
|
|
|
|
}
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
no_converter:
|
|
|
|
{
|
2011-08-18 17:15:03 +00:00
|
|
|
GST_ERROR_OBJECT (base, "could not find converter");
|
2004-05-25 20:14:10 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2003-04-14 01:20:30 +00:00
|
|
|
}
|
2003-07-19 22:58:41 +00:00
|
|
|
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_audio_convert_transform (GstBaseTransform * base, GstBuffer * inbuf,
|
|
|
|
GstBuffer * outbuf)
|
2003-04-14 01:20:30 +00:00
|
|
|
{
|
2011-03-27 14:35:28 +00:00
|
|
|
GstFlowReturn ret;
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
GstAudioConvert *this = GST_AUDIO_CONVERT (base);
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo srcmap, dstmap;
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
gint insize, outsize;
|
2012-01-20 15:11:54 +00:00
|
|
|
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
gint samples;
|
|
|
|
|
|
|
|
/* get amount of samples to convert. */
|
2011-08-18 17:15:03 +00:00
|
|
|
samples = gst_buffer_get_size (inbuf) / this->ctx.in.bpf;
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
|
|
|
|
/* get in/output sizes, to see if the buffers we got are of correct
|
|
|
|
* sizes */
|
2009-08-08 13:54:02 +00:00
|
|
|
if (!audio_convert_get_sizes (&this->ctx, samples, &insize, &outsize))
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
goto error;
|
|
|
|
|
2007-01-30 11:29:17 +00:00
|
|
|
if (insize == 0 || outsize == 0)
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
|
2011-03-27 14:35:28 +00:00
|
|
|
/* get src and dst data */
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (inbuf, &srcmap, GST_MAP_READ);
|
|
|
|
gst_buffer_map (outbuf, &dstmap, GST_MAP_WRITE);
|
2011-03-27 14:35:28 +00:00
|
|
|
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
/* check in and outsize */
|
2012-01-20 15:11:54 +00:00
|
|
|
if (srcmap.size < insize)
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
goto wrong_size;
|
2012-01-20 15:11:54 +00:00
|
|
|
if (dstmap.size < outsize)
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
goto wrong_size;
|
|
|
|
|
|
|
|
/* and convert the samples */
|
2008-03-21 15:58:44 +00:00
|
|
|
if (!GST_BUFFER_FLAG_IS_SET (inbuf, GST_BUFFER_FLAG_GAP)) {
|
2012-01-20 15:11:54 +00:00
|
|
|
if (!audio_convert_convert (&this->ctx, srcmap.data, dstmap.data,
|
2009-08-08 13:54:02 +00:00
|
|
|
samples, gst_buffer_is_writable (inbuf)))
|
2008-03-21 15:58:44 +00:00
|
|
|
goto convert_error;
|
|
|
|
} else {
|
|
|
|
/* Create silence buffer */
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_audio_format_fill_silence (this->ctx.out.finfo, dstmap.data, outsize);
|
2008-03-21 15:58:44 +00:00
|
|
|
}
|
2011-03-27 14:35:28 +00:00
|
|
|
ret = GST_FLOW_OK;
|
2005-12-02 10:17:35 +00:00
|
|
|
|
2011-03-27 14:35:28 +00:00
|
|
|
done:
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuf, &dstmap);
|
|
|
|
gst_buffer_unmap (inbuf, &srcmap);
|
2003-04-14 01:20:30 +00:00
|
|
|
|
2011-03-27 14:35:28 +00:00
|
|
|
return ret;
|
2003-07-19 22:58:41 +00:00
|
|
|
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
/* ERRORS */
|
|
|
|
error:
|
|
|
|
{
|
2007-03-09 12:22:53 +00:00
|
|
|
GST_ELEMENT_ERROR (this, STREAM, FORMAT,
|
|
|
|
(NULL), ("cannot get input/output sizes for %d samples", samples));
|
gst/audioconvert/: Cleanups, librarify a bit, optimize, better negotiation and more.
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (if), (float),
(audio_convert_get_func_index), (check_default),
(audio_convert_clean_fmt), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_get_sizes),
(get_temp_buffer), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_class_init), (gst_audio_convert_init),
(gst_audio_convert_dispose), (gst_audio_convert_parse_caps),
(gst_audio_convert_get_unit_size),
(gst_audio_convert_transform_caps),
(gst_audio_convert_fixate_caps), (gst_audio_convert_set_caps),
(gst_audio_convert_transform_ip), (gst_audio_convert_transform):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstchannelmix.c: (gst_channel_mix_unset_matrix),
(gst_channel_mix_fill_identical),
(gst_channel_mix_fill_compatible), (gst_channel_mix_detect_pos),
(gst_channel_mix_fill_one_other), (gst_channel_mix_fill_others),
(gst_channel_mix_fill_normalize), (gst_channel_mix_fill_matrix),
(gst_channel_mix_setup_matrix), (gst_channel_mix_passthrough),
(gst_channel_mix_mix):
* gst/audioconvert/gstchannelmix.h:
Cleanups, librarify a bit, optimize, better negotiation and more.
2005-08-26 15:43:56 +00:00
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
|
|
|
wrong_size:
|
|
|
|
{
|
2007-03-09 12:22:53 +00:00
|
|
|
GST_ELEMENT_ERROR (this, STREAM, FORMAT,
|
|
|
|
(NULL),
|
2011-08-09 14:39:31 +00:00
|
|
|
("input/output buffers are of wrong size in: %" G_GSIZE_FORMAT " < %d"
|
|
|
|
" or out: %" G_GSIZE_FORMAT " < %d",
|
2012-01-20 15:11:54 +00:00
|
|
|
srcmap.size, insize, dstmap.size, outsize));
|
2011-03-27 14:35:28 +00:00
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
2005-12-02 10:17:35 +00:00
|
|
|
}
|
|
|
|
convert_error:
|
|
|
|
{
|
2007-03-09 12:22:53 +00:00
|
|
|
GST_ELEMENT_ERROR (this, STREAM, FORMAT,
|
|
|
|
(NULL), ("error while converting"));
|
2011-03-27 14:35:28 +00:00
|
|
|
ret = GST_FLOW_ERROR;
|
|
|
|
goto done;
|
2003-04-14 01:20:30 +00:00
|
|
|
}
|
|
|
|
}
|
gst/audioconvert/: Implement dithering and noise shaping in audioconvert. By default now
Original commit message from CVS:
* gst/audioconvert/Makefile.am:
* gst/audioconvert/audioconvert.c: (audio_convert_get_func_index),
(check_default), (audio_convert_prepare_context),
(audio_convert_clean_context), (audio_convert_convert):
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioconvert.c:
(gst_audio_convert_dithering_get_type),
(gst_audio_convert_ns_get_type), (gst_audio_convert_class_init),
(gst_audio_convert_init), (gst_audio_convert_set_caps),
(gst_audio_convert_set_property), (gst_audio_convert_get_property):
* gst/audioconvert/gstaudioconvert.h:
* gst/audioconvert/gstaudioquantize.c:
(gst_audio_quantize_setup_noise_shaping),
(gst_audio_quantize_free_noise_shaping),
(gst_audio_quantize_setup_dither),
(gst_audio_quantize_free_dither),
(gst_audio_quantize_setup_quantize_func),
(gst_audio_quantize_setup), (gst_audio_quantize_free):
* gst/audioconvert/gstaudioquantize.h:
Implement dithering and noise shaping in audioconvert. By default now
TPDF dithering (and no noise shaping) will be used when converting
from a higher bit depth to 20 bit depth or smaller, otherwise
everything will be as it is now.
For the last audioconvert in a pipeline it would make sense to
use some kind of noise shaping, enabling it by default for all
conversions would give undesired results though. Fixes #360246.
* tests/check/elements/audioconvert.c: (setup_audioconvert),
(GST_START_TEST):
Adjust unit test for the new audioconvert.
2007-06-28 20:37:58 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_audio_convert_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstAudioConvert *this = GST_AUDIO_CONVERT (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_DITHERING:
|
|
|
|
this->dither = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
case ARG_NOISE_SHAPING:
|
|
|
|
this->ns = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_audio_convert_get_property (GObject * object, guint prop_id,
|
|
|
|
GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstAudioConvert *this = GST_AUDIO_CONVERT (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case ARG_DITHERING:
|
|
|
|
g_value_set_enum (value, this->dither);
|
|
|
|
break;
|
|
|
|
case ARG_NOISE_SHAPING:
|
|
|
|
g_value_set_enum (value, this->ns);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|