Commit graph

15 commits

Author SHA1 Message Date
Wim Taymans
5cf367ae57 audioconvert: rework audioconvert
Rewrite audioconvert to try to make it more clear what steps are
executed during conversion.
Add passthrough step that just does a memcpy when possible.
Add ORC optimized dither and quantization functions.
Implement noise-shaping on S32 samples only and allow for arbitrary
noise shaping coefficients if we want this later.
2015-10-30 17:51:47 +01:00
Wim Taymans
26d469a04b audioquantize: make helper for add with saturation 2015-10-30 17:51:47 +01:00
Wim Taymans
cd6c29e071 audioconvert: make the quantizer a reusable object
Turn the quantizer into a reusable object.
2015-10-28 11:36:18 +01:00
Wim Taymans
8d4cd51e59 audioquantize: fix 8-pole noise shaping
Fix the 8-pole noise shaping error update. We were mixing errors from
different channels.
2015-10-28 11:36:18 +01:00
Wim Taymans
2b626a5adf audioconvert: use pack/unpack functions
Rework the converter to use the pack/unpack functions
Because the unpack functions can only unpack to 1 format, add a separate
conversion step for doubles when the unpack function produces int.
Do conversion to S32 in the quantize function directly.
Tweak the conversion factor for doing float->int conversion slightly to
get the full range of negative samples, use clamp to make sure we don't
exceed our int range on the positive axis (see also #755301)
2015-10-23 16:58:17 +02:00
Ilya Konstantinov
3dc3aa4e3b audioconvert: Eliminate unsigned quantizers
audio_convert_convert unpacks to default format (signed) before calling
quantize, and the unsigned variants were equivalent to signed anyway,
so we just get rid of them.
2015-03-24 16:52:07 +01:00
Ilya Konstantinov
7b398701cf audioconvert: Avoid int division in quantization
Since range size is always 2^n, we can simply use modulo (implemented
with a bitmask).

The previous implementation used 64-bit integer division, which is
done in software on ARMv7. Although the divisor was constant, the
division could not be transformed into "multiplication by magic number"
since the dividend was 64-bit.

The now-unused and not-so-fast gst_fast_random_(u)int32_range functions
were removed.

Also, implementing bug fixes:

1) ADD_DITHER_TPDF_HF_I no longer discards bias.

2) We change TPDF's noise range to be the same as RPDF's. Previously,
RPDF's noise ranged:
  { bias - dither, bias + dither }
while TPDF's noise ranged:
  { bias/2 - dither/2, bias/2 + dither/2 - 1 } +
  { bias/2 - dither/2, bias/2 + dither/2 - 1 } =
  { bias - dither, bias + dither - 2 }
Now, both range:
  { bias - dither, bias + dither - 1 }

https://bugzilla.gnome.org/show_bug.cgi?id=746661
2015-03-24 16:52:07 +01:00
Sebastian Dröge
2bd4ea6e8e Constify some static arrays everywhere 2015-01-21 09:49:47 +01:00
Tim-Philipp Müller
5f59b4f7ee Fix FSF address
https://bugzilla.gnome.org/show_bug.cgi?id=687520
2012-11-03 23:05:09 +00:00
Wim Taymans
0213407fbc audio: rename INT -> INTEGER
Spell INTEGER fully instead of using the int abreviation.
Remove some old functions.
2011-08-20 10:49:17 +02:00
Wim Taymans
dae848818d audio: rework audio caps.
Rework the audio caps similar to the video caps. Remove
width/depth/endianness/signed fields and replace with a simple string
format and media type audio/x-raw.
Create a GstAudioInfo and some helper methods to parse caps.
Remove duplicate code from the ringbuffer and replace with audio info.
Use AudioInfo in the base audio filter class.
Port elements to new API.
2011-08-18 19:15:03 +02:00
Sebastian Dröge
ef5004e56e gst/audioconvert/: Implement a linear congruential generator as pseudo random number generator for the dither noise. ...
Original commit message from CVS:
* gst/audioconvert/audioconvert.h:
* gst/audioconvert/gstaudioquantize.c:
(gst_audio_quantize_setup_dither),
(gst_audio_quantize_free_dither):
* gst/audioconvert/gstfastrandom.h:
Implement a linear congruential generator as pseudo random number
generator for the dither noise. This is about 2 times faster than
using GLib's mersenne twister. Also this uses only integer math for
generating integers while GLib internally uses floating point math.
2008-07-23 18:34:19 +00:00
Sebastian Dröge
83f0729394 Remove some unused code.
Original commit message from CVS:
* gst-libs/gst/audio/gstaudiosink.c: (audioringbuffer_thread_func):
* gst-libs/gst/audio/gstaudiosrc.c: (audioringbuffer_thread_func):
* gst/tcp/gsttcp.c: (gst_tcp_socket_write):
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_get_fps_list):
Remove some unused code.
* gst/audioconvert/gstaudioquantize.c:
(gst_audio_quantize_free_noise_shaping):
Don't return before freeing the noise shaping history.
2008-05-04 15:02:20 +00:00
Jens Granseuer
ef33f2fdc4 gst/audioconvert/gstaudioquantize.c: Fix C89 incompatibilities and spelling of explanations. Fixes #463215.
Original commit message from CVS:
Patch by: Jens Granseuer <jensgr at gmx dot net>
* gst/audioconvert/gstaudioquantize.c:
Fix C89 incompatibilities and spelling of explanations. Fixes #463215.
2007-08-03 19:40:14 +00:00
Sebastian Dröge
dbb857b93b 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