mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 12:41:05 +00:00
dbb857b93b
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.
124 lines
3.3 KiB
C
124 lines
3.3 KiB
C
/* GStreamer
|
|
* Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
|
*
|
|
* audioconvert.h: audio format conversion library
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#ifndef __AUDIO_CONVERT_H__
|
|
#define __AUDIO_CONVERT_H__
|
|
|
|
#include <gst/gst.h>
|
|
#include <gst/audio/multichannel.h>
|
|
|
|
typedef enum
|
|
{
|
|
DITHER_NONE = 0,
|
|
DITHER_RPDF,
|
|
DITHER_TPDF,
|
|
DITHER_TPDF_HF
|
|
} DitherType;
|
|
|
|
typedef enum
|
|
{
|
|
NOISE_SHAPING_NONE = 0,
|
|
NOISE_SHAPING_ERROR_FEEDBACK,
|
|
NOISE_SHAPING_SIMPLE,
|
|
NOISE_SHAPING_MEDIUM,
|
|
NOISE_SHAPING_HIGH
|
|
} NoiseShapingType;
|
|
|
|
typedef struct _AudioConvertCtx AudioConvertCtx;
|
|
typedef struct _AudioConvertFmt AudioConvertFmt;
|
|
|
|
struct _AudioConvertFmt
|
|
{
|
|
/* general caps */
|
|
gboolean is_int;
|
|
gint endianness;
|
|
gint width;
|
|
gint rate;
|
|
gint channels;
|
|
GstAudioChannelPosition *pos;
|
|
|
|
/* int audio caps */
|
|
gboolean sign;
|
|
gint depth;
|
|
|
|
gint unit_size;
|
|
};
|
|
|
|
typedef void (*AudioConvertUnpack) (gpointer src, gpointer dst, gint scale,
|
|
gint count);
|
|
typedef void (*AudioConvertPack) (gpointer src, gpointer dst, gint scale,
|
|
gint count);
|
|
|
|
typedef void (*AudioConvertMix) (AudioConvertCtx *, gpointer, gpointer, gint);
|
|
typedef void (*AudioConvertQuantize) (AudioConvertCtx * ctx, gpointer src,
|
|
gpointer dst, gint count);
|
|
|
|
struct _AudioConvertCtx
|
|
{
|
|
AudioConvertFmt in;
|
|
AudioConvertFmt out;
|
|
|
|
AudioConvertUnpack unpack;
|
|
AudioConvertPack pack;
|
|
|
|
/* channel conversion matrix, m[in_channels][out_channels].
|
|
* If identity matrix, passthrough applies. */
|
|
gfloat **matrix;
|
|
/* temp storage for channelmix */
|
|
gpointer tmp;
|
|
|
|
gboolean in_default;
|
|
gboolean mix_passthrough;
|
|
gboolean out_default;
|
|
|
|
gpointer tmpbuf;
|
|
gint tmpbufsize;
|
|
|
|
gint in_scale;
|
|
gint out_scale;
|
|
|
|
AudioConvertMix channel_mix;
|
|
|
|
AudioConvertQuantize quantize;
|
|
DitherType dither;
|
|
NoiseShapingType ns;
|
|
/* random number generate for dither noise */
|
|
GRand *dither_random;
|
|
/* last random number generated per channel for hifreq TPDF dither */
|
|
gpointer last_random;
|
|
/* contains the past quantization errors, error[out_channels][count] */
|
|
gdouble *error_buf;
|
|
};
|
|
|
|
gboolean audio_convert_clean_fmt (AudioConvertFmt * fmt);
|
|
|
|
gboolean audio_convert_prepare_context (AudioConvertCtx * ctx,
|
|
AudioConvertFmt * in, AudioConvertFmt * out, DitherType dither,
|
|
NoiseShapingType ns);
|
|
gboolean audio_convert_get_sizes (AudioConvertCtx * ctx, gint samples,
|
|
gint * srcsize, gint * dstsize);
|
|
|
|
gboolean audio_convert_clean_context (AudioConvertCtx * ctx);
|
|
|
|
gboolean audio_convert_convert (AudioConvertCtx * ctx, gpointer src,
|
|
gpointer dst, gint samples, gboolean src_writable);
|
|
|
|
#endif /* __AUDIO_CONVERT_H__ */
|