2005-08-20 18:07:10 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
|
|
|
* unit test for volume
|
|
|
|
*
|
|
|
|
* Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 23:05:09 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2005-08-20 18:07:10 +00:00
|
|
|
*/
|
|
|
|
|
2018-01-16 18:14:59 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2005-08-20 18:07:10 +00:00
|
|
|
|
gst/adder/gstadder.c: Make it easier to copy&paste
Original commit message from CVS:
* gst/adder/gstadder.c: (gst_adder_get_type):
Make it easier to copy&paste
* gst/volume/Makefile.am:
* gst/volume/gstvolume.c: (volume_update_real_volume),
(gst_volume_set_volume), (gst_volume_set_mute),
(gst_volume_class_init), (volume_process_int16), (volume_set_caps),
(volume_transform_ip), (volume_update_mute),
(volume_update_volume):
* gst/volume/gstvolume.h:
Add own debug category, move duplicate code to helper function, fix
property texts, add more comments and prepare ffor liboil-goodness
* tests/check/Makefile.am:
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
add test for mute and passtrough case, be a bit more verbose to track
failure
* tests/check/generic/states.c: (GST_START_TEST):
catch elements that fail to instantiate
2006-05-28 19:42:27 +00:00
|
|
|
#include <gst/base/gstbasetransform.h>
|
2005-08-20 18:07:10 +00:00
|
|
|
#include <gst/check/gstcheck.h>
|
2012-01-04 15:41:53 +00:00
|
|
|
#include <gst/audio/streamvolume.h>
|
2011-11-04 14:23:25 +00:00
|
|
|
#include <gst/controller/gstinterpolationcontrolsource.h>
|
2012-01-31 15:12:33 +00:00
|
|
|
#include <gst/controller/gstdirectcontrolbinding.h>
|
2005-08-20 18:07:10 +00:00
|
|
|
|
|
|
|
/* For ease of programming we use globals to keep refs for our floating
|
|
|
|
* src and sink pads we create; otherwise we always have to do get_pad,
|
|
|
|
* get_peer, and then remove references in every test function */
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type):
* ext/alsa/gstalsasink.c: (set_hwparams):
* ext/alsa/gstalsasrc.c: (set_hwparams):
* ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri):
* ext/ogg/gstoggmux.h:
* ext/ogg/gstogmparse.c:
* gst-libs/gst/audio/audio.c:
* gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc):
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new):
* gst-libs/gst/rtp/gstbasertppayload.c:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_packet_bye_get_reason):
* gst/audioconvert/gstaudioconvert.c:
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/imgconvert.c:
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/typefind/gsttypefindfunctions.c:
* gst/videoscale/vs_4tap.c:
* gst/videoscale/vs_4tap.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init),
(gst_v4lsrc_try_capture):
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new):
* tests/check/elements/audioconvert.c:
* tests/check/elements/audioresample.c:
(fail_unless_perfect_stream):
* tests/check/elements/audiotestsrc.c: (setup_audiotestsrc):
* tests/check/elements/decodebin.c:
* tests/check/elements/gdpdepay.c: (setup_gdpdepay),
(setup_gdpdepay_streamheader):
* tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST),
(setup_gdppay_streamheader):
* tests/check/elements/gnomevfssink.c: (setup_gnomevfssink):
* tests/check/elements/multifdsink.c: (setup_multifdsink):
* tests/check/elements/textoverlay.c:
* tests/check/elements/videorate.c: (setup_videorate):
* tests/check/elements/videotestsrc.c: (setup_videotestsrc):
* tests/check/elements/volume.c: (setup_volume):
* tests/check/elements/vorbisdec.c: (setup_vorbisdec):
* tests/check/elements/vorbistag.c:
* tests/check/generic/clock-selection.c:
* tests/check/generic/states.c: (setup), (teardown):
* tests/check/libs/cddabasesrc.c:
* tests/check/libs/video.c:
* tests/check/pipelines/gio.c:
* tests/check/pipelines/oggmux.c:
* tests/check/pipelines/simple-launch-lines.c:
(simple_launch_lines_suite):
* tests/check/pipelines/streamheader.c:
* tests/check/pipelines/theoraenc.c:
* tests/check/pipelines/vorbisdec.c:
* tests/check/pipelines/vorbisenc.c:
* tests/examples/seek/scrubby.c:
* tests/examples/seek/seek.c: (query_positions_elems),
(query_positions_pads):
* tests/icles/stress-xoverlay.c: (myclock):
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers and using "foo (void)" instead
of "foo ()" for declarations.
* win32/common/libgstrtp.def:
Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
|
|
|
static GstPad *mysrcpad, *mysinkpad;
|
2005-08-20 18:07:10 +00:00
|
|
|
|
2011-09-29 11:46:36 +00:00
|
|
|
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
|
|
|
|
#define FORMATS1 "{ S8, S16LE, S24LE, S32LE, F32LE, F64LE }"
|
|
|
|
#define FORMATS2 "S8"
|
|
|
|
#define FORMATS3 "S16LE"
|
|
|
|
#define FORMATS4 "S24LE"
|
|
|
|
#define FORMATS5 "S32LE"
|
|
|
|
#define FORMATS6 "F32LE"
|
|
|
|
#define FORMATS7 "F64LE"
|
|
|
|
#define FORMATS8 "U16LE"
|
|
|
|
#else
|
|
|
|
#define FORMATS1 "{ S8, S16BE, S24BE, S32BE, F32BE, F64BE }"
|
|
|
|
#define FORMATS2 "S8"
|
|
|
|
#define FORMATS3 "S16BE"
|
|
|
|
#define FORMATS4 "S24BE"
|
|
|
|
#define FORMATS5 "S32BE"
|
|
|
|
#define FORMATS6 "F32BE"
|
|
|
|
#define FORMATS7 "F64BE"
|
|
|
|
#define FORMATS8 "U16BE"
|
|
|
|
#endif
|
2005-08-20 18:07:10 +00:00
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
#define VOLUME_CAPS_TEMPLATE_STRING \
|
2011-09-29 11:46:36 +00:00
|
|
|
"audio/x-raw, " \
|
|
|
|
"format = (string) "FORMATS1", " \
|
2005-12-06 19:42:02 +00:00
|
|
|
"channels = (int) [ 1, MAX ], " \
|
2012-02-03 14:01:50 +00:00
|
|
|
"rate = (int) [ 1, MAX ], " \
|
|
|
|
"layout = (string) interleaved"
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
#define VOLUME_CAPS_STRING_S8 \
|
2011-09-29 11:46:36 +00:00
|
|
|
"audio/x-raw, " \
|
2012-02-03 14:01:50 +00:00
|
|
|
"format = (string) "FORMATS2", " \
|
2007-09-05 21:20:12 +00:00
|
|
|
"channels = (int) 1, " \
|
2012-02-03 14:01:50 +00:00
|
|
|
"rate = (int) 44100," \
|
|
|
|
"layout = (string) interleaved"
|
2005-08-20 18:07:10 +00:00
|
|
|
|
2007-09-05 21:20:12 +00:00
|
|
|
#define VOLUME_CAPS_STRING_S16 \
|
2011-09-29 11:46:36 +00:00
|
|
|
"audio/x-raw, " \
|
2012-02-03 14:01:50 +00:00
|
|
|
"format = (string) "FORMATS3", " \
|
2005-12-06 19:42:02 +00:00
|
|
|
"channels = (int) 1, " \
|
2012-02-03 14:01:50 +00:00
|
|
|
"rate = (int) 44100," \
|
|
|
|
"layout = (string) interleaved"
|
2005-08-20 18:07:10 +00:00
|
|
|
|
2007-09-05 21:20:12 +00:00
|
|
|
#define VOLUME_CAPS_STRING_S24 \
|
2011-09-29 11:46:36 +00:00
|
|
|
"audio/x-raw, " \
|
2012-02-03 14:01:50 +00:00
|
|
|
"format = (string) "FORMATS4", " \
|
2007-09-05 21:20:12 +00:00
|
|
|
"channels = (int) 1, " \
|
2012-02-03 14:01:50 +00:00
|
|
|
"rate = (int) 44100," \
|
|
|
|
"layout = (string) interleaved"
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
#define VOLUME_CAPS_STRING_S32 \
|
2011-09-29 11:46:36 +00:00
|
|
|
"audio/x-raw, " \
|
2012-02-03 14:01:50 +00:00
|
|
|
"format = (string) "FORMATS5", " \
|
2007-09-05 21:20:12 +00:00
|
|
|
"channels = (int) 1, " \
|
2012-02-03 14:01:50 +00:00
|
|
|
"rate = (int) 44100," \
|
|
|
|
"layout = (string) interleaved"
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
#define VOLUME_CAPS_STRING_F32 \
|
2011-09-29 11:46:36 +00:00
|
|
|
"audio/x-raw, " \
|
2012-02-03 14:01:50 +00:00
|
|
|
"format = (string) "FORMATS6", " \
|
2007-09-05 21:20:12 +00:00
|
|
|
"channels = (int) 1, " \
|
2012-02-03 14:01:50 +00:00
|
|
|
"rate = (int) 44100," \
|
|
|
|
"layout = (string) interleaved"
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
#define VOLUME_CAPS_STRING_F64 \
|
2011-09-29 11:46:36 +00:00
|
|
|
"audio/x-raw, " \
|
2012-02-03 14:01:50 +00:00
|
|
|
"format = (string) "FORMATS7", " \
|
2007-09-05 21:20:12 +00:00
|
|
|
"channels = (int) 1, " \
|
2012-02-03 14:01:50 +00:00
|
|
|
"rate = (int) 44100," \
|
|
|
|
"layout = (string) interleaved"
|
2007-09-05 21:20:12 +00:00
|
|
|
|
2005-12-06 19:42:02 +00:00
|
|
|
#define VOLUME_WRONG_CAPS_STRING \
|
2011-09-29 11:46:36 +00:00
|
|
|
"audio/x-raw, " \
|
2012-02-03 14:01:50 +00:00
|
|
|
"format = (string) "FORMATS8", " \
|
2005-12-06 19:42:02 +00:00
|
|
|
"channels = (int) 1, " \
|
2012-02-03 14:01:50 +00:00
|
|
|
"rate = (int) 44100," \
|
|
|
|
"layout = (string) interleaved"
|
2005-08-20 20:40:25 +00:00
|
|
|
|
|
|
|
|
2005-08-20 18:07:10 +00:00
|
|
|
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (VOLUME_CAPS_TEMPLATE_STRING)
|
|
|
|
);
|
|
|
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS (VOLUME_CAPS_TEMPLATE_STRING)
|
|
|
|
);
|
|
|
|
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type):
* ext/alsa/gstalsasink.c: (set_hwparams):
* ext/alsa/gstalsasrc.c: (set_hwparams):
* ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri):
* ext/ogg/gstoggmux.h:
* ext/ogg/gstogmparse.c:
* gst-libs/gst/audio/audio.c:
* gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc):
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new):
* gst-libs/gst/rtp/gstbasertppayload.c:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_packet_bye_get_reason):
* gst/audioconvert/gstaudioconvert.c:
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/imgconvert.c:
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/typefind/gsttypefindfunctions.c:
* gst/videoscale/vs_4tap.c:
* gst/videoscale/vs_4tap.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init),
(gst_v4lsrc_try_capture):
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new):
* tests/check/elements/audioconvert.c:
* tests/check/elements/audioresample.c:
(fail_unless_perfect_stream):
* tests/check/elements/audiotestsrc.c: (setup_audiotestsrc):
* tests/check/elements/decodebin.c:
* tests/check/elements/gdpdepay.c: (setup_gdpdepay),
(setup_gdpdepay_streamheader):
* tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST),
(setup_gdppay_streamheader):
* tests/check/elements/gnomevfssink.c: (setup_gnomevfssink):
* tests/check/elements/multifdsink.c: (setup_multifdsink):
* tests/check/elements/textoverlay.c:
* tests/check/elements/videorate.c: (setup_videorate):
* tests/check/elements/videotestsrc.c: (setup_videotestsrc):
* tests/check/elements/volume.c: (setup_volume):
* tests/check/elements/vorbisdec.c: (setup_vorbisdec):
* tests/check/elements/vorbistag.c:
* tests/check/generic/clock-selection.c:
* tests/check/generic/states.c: (setup), (teardown):
* tests/check/libs/cddabasesrc.c:
* tests/check/libs/video.c:
* tests/check/pipelines/gio.c:
* tests/check/pipelines/oggmux.c:
* tests/check/pipelines/simple-launch-lines.c:
(simple_launch_lines_suite):
* tests/check/pipelines/streamheader.c:
* tests/check/pipelines/theoraenc.c:
* tests/check/pipelines/vorbisdec.c:
* tests/check/pipelines/vorbisenc.c:
* tests/examples/seek/scrubby.c:
* tests/examples/seek/seek.c: (query_positions_elems),
(query_positions_pads):
* tests/icles/stress-xoverlay.c: (myclock):
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers and using "foo (void)" instead
of "foo ()" for declarations.
* win32/common/libgstrtp.def:
Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
|
|
|
static GstElement *
|
|
|
|
setup_volume (void)
|
2005-08-20 18:07:10 +00:00
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
|
|
|
|
GST_DEBUG ("setup_volume");
|
2005-08-21 10:43:45 +00:00
|
|
|
volume = gst_check_setup_element ("volume");
|
2012-01-04 15:41:53 +00:00
|
|
|
mysrcpad = gst_check_setup_src_pad (volume, &srctemplate);
|
|
|
|
mysinkpad = gst_check_setup_sink_pad (volume, &sinktemplate);
|
2005-08-30 19:54:35 +00:00
|
|
|
gst_pad_set_active (mysrcpad, TRUE);
|
|
|
|
gst_pad_set_active (mysinkpad, TRUE);
|
|
|
|
|
2005-08-20 18:07:10 +00:00
|
|
|
return volume;
|
|
|
|
}
|
|
|
|
|
Correct all relevant warnings found by the sparse semantic code analyzer. This include marking several symbols static...
Original commit message from CVS:
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_get_type):
* ext/alsa/gstalsasink.c: (set_hwparams):
* ext/alsa/gstalsasrc.c: (set_hwparams):
* ext/gio/gstgio.c: (gst_gio_uri_handler_get_uri):
* ext/ogg/gstoggmux.h:
* ext/ogg/gstogmparse.c:
* gst-libs/gst/audio/audio.c:
* gst-libs/gst/fft/kiss_fft_f64.c: (kiss_fft_f64_alloc):
* gst-libs/gst/pbutils/missing-plugins.c:
(gst_missing_uri_sink_message_new),
(gst_missing_element_message_new),
(gst_missing_decoder_message_new),
(gst_missing_encoder_message_new):
* gst-libs/gst/rtp/gstbasertppayload.c:
* gst-libs/gst/rtp/gstrtcpbuffer.c:
(gst_rtcp_packet_bye_get_reason):
* gst/audioconvert/gstaudioconvert.c:
* gst/audioresample/gstaudioresample.c:
* gst/ffmpegcolorspace/imgconvert.c:
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/typefind/gsttypefindfunctions.c:
* gst/videoscale/vs_4tap.c:
* gst/videoscale/vs_4tap.h:
* sys/v4l/gstv4lelement.c:
* sys/v4l/gstv4lsrc.c: (gst_v4lsrc_get_any_caps):
* sys/v4l/v4l_calls.c:
* sys/v4l/v4lsrc_calls.c: (gst_v4lsrc_capture_init),
(gst_v4lsrc_try_capture):
* sys/ximage/ximagesink.c: (gst_ximagesink_check_xshm_calls),
(gst_ximagesink_ximage_new):
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls),
(gst_xvimagesink_xvimage_new):
* tests/check/elements/audioconvert.c:
* tests/check/elements/audioresample.c:
(fail_unless_perfect_stream):
* tests/check/elements/audiotestsrc.c: (setup_audiotestsrc):
* tests/check/elements/decodebin.c:
* tests/check/elements/gdpdepay.c: (setup_gdpdepay),
(setup_gdpdepay_streamheader):
* tests/check/elements/gdppay.c: (setup_gdppay), (GST_START_TEST),
(setup_gdppay_streamheader):
* tests/check/elements/gnomevfssink.c: (setup_gnomevfssink):
* tests/check/elements/multifdsink.c: (setup_multifdsink):
* tests/check/elements/textoverlay.c:
* tests/check/elements/videorate.c: (setup_videorate):
* tests/check/elements/videotestsrc.c: (setup_videotestsrc):
* tests/check/elements/volume.c: (setup_volume):
* tests/check/elements/vorbisdec.c: (setup_vorbisdec):
* tests/check/elements/vorbistag.c:
* tests/check/generic/clock-selection.c:
* tests/check/generic/states.c: (setup), (teardown):
* tests/check/libs/cddabasesrc.c:
* tests/check/libs/video.c:
* tests/check/pipelines/gio.c:
* tests/check/pipelines/oggmux.c:
* tests/check/pipelines/simple-launch-lines.c:
(simple_launch_lines_suite):
* tests/check/pipelines/streamheader.c:
* tests/check/pipelines/theoraenc.c:
* tests/check/pipelines/vorbisdec.c:
* tests/check/pipelines/vorbisenc.c:
* tests/examples/seek/scrubby.c:
* tests/examples/seek/seek.c: (query_positions_elems),
(query_positions_pads):
* tests/icles/stress-xoverlay.c: (myclock):
Correct all relevant warnings found by the sparse semantic code
analyzer. This include marking several symbols static, using
NULL instead of 0 for pointers and using "foo (void)" instead
of "foo ()" for declarations.
* win32/common/libgstrtp.def:
Add gst_rtp_buffer_set_extension_data to the symbol definition file.
2008-03-03 06:04:31 +00:00
|
|
|
static void
|
2005-08-20 18:07:10 +00:00
|
|
|
cleanup_volume (GstElement * volume)
|
|
|
|
{
|
|
|
|
GST_DEBUG ("cleanup_volume");
|
|
|
|
|
2005-08-29 11:18:29 +00:00
|
|
|
g_list_foreach (buffers, (GFunc) gst_mini_object_unref, NULL);
|
|
|
|
g_list_free (buffers);
|
|
|
|
buffers = NULL;
|
|
|
|
|
2006-12-21 08:12:26 +00:00
|
|
|
gst_pad_set_active (mysrcpad, FALSE);
|
|
|
|
gst_pad_set_active (mysinkpad, FALSE);
|
2005-08-21 10:43:45 +00:00
|
|
|
gst_check_teardown_src_pad (volume);
|
|
|
|
gst_check_teardown_sink_pad (volume);
|
|
|
|
gst_check_teardown_element (volume);
|
2005-08-20 18:07:10 +00:00
|
|
|
}
|
|
|
|
|
2009-09-11 13:04:42 +00:00
|
|
|
GST_START_TEST (test_get_set)
|
|
|
|
{
|
|
|
|
GstElement *volume = gst_element_factory_make ("volume", NULL);
|
|
|
|
gdouble val;
|
|
|
|
|
|
|
|
fail_unless (volume != NULL);
|
|
|
|
g_object_get (G_OBJECT (volume), "volume", &val, NULL);
|
|
|
|
fail_unless (val == 1.0);
|
|
|
|
fail_unless (val == gst_stream_volume_get_volume (GST_STREAM_VOLUME (volume),
|
|
|
|
GST_STREAM_VOLUME_FORMAT_LINEAR));
|
|
|
|
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
|
|
|
|
g_object_get (G_OBJECT (volume), "volume", &val, NULL);
|
|
|
|
fail_unless (val == 0.5);
|
|
|
|
fail_unless (val == gst_stream_volume_get_volume (GST_STREAM_VOLUME (volume),
|
|
|
|
GST_STREAM_VOLUME_FORMAT_LINEAR));
|
|
|
|
|
|
|
|
gst_stream_volume_set_volume (GST_STREAM_VOLUME (volume),
|
|
|
|
GST_STREAM_VOLUME_FORMAT_LINEAR, 1.0);
|
|
|
|
g_object_get (G_OBJECT (volume), "volume", &val, NULL);
|
|
|
|
fail_unless (val == 1.0);
|
|
|
|
fail_unless (val == gst_stream_volume_get_volume (GST_STREAM_VOLUME (volume),
|
|
|
|
GST_STREAM_VOLUME_FORMAT_LINEAR));
|
|
|
|
|
|
|
|
gst_object_unref (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2007-09-05 21:20:12 +00:00
|
|
|
GST_START_TEST (test_unity_s8)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint8 in[2] = { 64, -16 };
|
2012-02-03 14:01:50 +00:00
|
|
|
gint8 *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (2);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 2);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2012-02-03 14:01:50 +00:00
|
|
|
res = (gint8 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], res[0], res[1]);
|
|
|
|
fail_unless (memcmp (res, in, 2) == 0);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_half_s8)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint8 in[2] = { 64, -16 };
|
|
|
|
gint8 out[2] = { 32, -8 };
|
2012-02-03 14:01:50 +00:00
|
|
|
gint8 *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (2);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 2);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2012-02-03 14:01:50 +00:00
|
|
|
res = (gint8 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
|
|
|
|
res[1]);
|
|
|
|
fail_unless (memcmp (res, out, 2) == 0);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_double_s8)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint8 in[2] = { 64, -16 };
|
|
|
|
gint8 out[2] = { 127, -32 }; /* notice the clamped sample */
|
2012-02-03 14:01:50 +00:00
|
|
|
gint8 *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (2);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 2);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2012-02-03 14:01:50 +00:00
|
|
|
res = (gint8 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
|
|
|
|
res[1]);
|
|
|
|
fail_unless (memcmp (res, out, 2) == 0);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2011-05-31 09:05:03 +00:00
|
|
|
GST_START_TEST (test_ten_s8)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint8 in[2] = { 64, -10 };
|
|
|
|
gint8 out[2] = { 127, -100 }; /* notice the clamped sample */
|
2012-02-03 14:01:50 +00:00
|
|
|
gint8 *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2011-05-31 09:05:03 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 10.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (2);
|
2012-01-04 15:41:53 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 2);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 2) == 0);
|
2011-05-31 09:05:03 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2011-05-31 09:05:03 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2012-02-03 14:01:50 +00:00
|
|
|
res = (gint8 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
|
|
|
|
res[1]);
|
|
|
|
fail_unless (memcmp (res, out, 2) == 0);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2011-05-31 09:05:03 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
GST_START_TEST (test_fifteen_s8)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint8 in[4] = { 1, -1, G_MAXINT8, G_MININT8 };
|
|
|
|
gint8 out[4] = { 15, -15, G_MAXINT8, G_MININT8 };
|
|
|
|
/* notice the clamped sample */
|
|
|
|
gint8 *res;
|
|
|
|
GstMapInfo map;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
// Maximal volume that is supported by the fixed point multiplication.
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 15.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (4);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 4);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 4) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
res = (gint8 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d", out[0],
|
|
|
|
out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
|
|
|
|
fail_unless (memcmp (res, out, 4) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_sixteen_s8)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint8 in[4] = { 1, -1, G_MAXINT8, G_MININT8 };
|
|
|
|
gint8 out[4] = { 16, -16, G_MAXINT8, G_MININT8 };
|
|
|
|
/* notice the clamped sample */
|
|
|
|
gint8 *res;
|
|
|
|
GstMapInfo map;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
// No longer using fixed point multiplication.
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 16.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (4);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 4);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 4) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
res = (gint8 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d", out[0],
|
|
|
|
out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
|
|
|
|
fail_unless (memcmp (res, out, 4) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_max_s8)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint8 in[4] = { 1, -1, G_MAXINT8, G_MININT8 };
|
|
|
|
gint8 out[4] = { G_MAXINT8, G_MININT8, G_MAXINT8, G_MININT8 };
|
|
|
|
/* notice the clamped sample */
|
|
|
|
gint8 *res;
|
|
|
|
GstMapInfo map;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
// No longer using fixed point multiplication.
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", G_MAXDOUBLE, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (4);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 4);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 4) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
res = (gint8 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d", out[0],
|
|
|
|
out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
|
|
|
|
fail_unless (memcmp (res, out, 4) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2007-09-05 21:20:12 +00:00
|
|
|
GST_START_TEST (test_mute_s8)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint8 in[2] = { 64, -16 };
|
|
|
|
gint8 out[2] = { 0, 0 };
|
2023-07-19 17:25:37 +00:00
|
|
|
gint8 *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "mute", TRUE, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (2);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 2);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S8);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2023-07-19 17:25:37 +00:00
|
|
|
res = (gint8 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", out[0], out[1], res[0],
|
|
|
|
res[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
fail_unless (memcmp (map.data, out, 2) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_unity_s16)
|
2005-08-20 18:07:10 +00:00
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
2005-10-11 01:37:11 +00:00
|
|
|
GstCaps *caps;
|
2005-08-20 18:07:10 +00:00
|
|
|
gint16 in[2] = { 16384, -256 };
|
2023-07-19 17:25:37 +00:00
|
|
|
gint16 *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2005-08-20 18:07:10 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
2005-09-02 15:43:18 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
2005-08-20 18:07:10 +00:00
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (4);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 4);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2005-10-11 01:37:11 +00:00
|
|
|
gst_caps_unref (caps);
|
2005-08-20 18:07:10 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
2005-08-20 20:40:25 +00:00
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
2005-08-20 18:07:10 +00:00
|
|
|
/* ... but it ends up being collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
2005-08-29 11:37:20 +00:00
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
2005-08-20 18:07:10 +00:00
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2023-07-19 17:25:37 +00:00
|
|
|
res = (gint16 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], res[0], res[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
fail_unless (memcmp (map.data, in, 4) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2005-08-20 18:07:10 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2007-09-05 21:20:12 +00:00
|
|
|
GST_START_TEST (test_half_s16)
|
2005-08-20 18:07:10 +00:00
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
2005-10-11 01:37:11 +00:00
|
|
|
GstCaps *caps;
|
2005-08-20 18:07:10 +00:00
|
|
|
gint16 in[2] = { 16384, -256 };
|
|
|
|
gint16 out[2] = { 8192, -128 };
|
2023-07-19 17:25:37 +00:00
|
|
|
gint16 *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2005-08-20 18:07:10 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
2005-09-02 15:43:18 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
2005-08-20 18:07:10 +00:00
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (4);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 4);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2005-10-11 01:37:11 +00:00
|
|
|
gst_caps_unref (caps);
|
2005-08-20 18:07:10 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
2005-08-20 20:40:25 +00:00
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
2005-08-20 18:07:10 +00:00
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
2005-08-29 11:37:20 +00:00
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
2005-08-20 18:07:10 +00:00
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2023-07-19 17:25:37 +00:00
|
|
|
res = (gint16 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], res[0], res[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
fail_unless (memcmp (map.data, out, 4) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2005-08-20 18:07:10 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2007-09-05 21:20:12 +00:00
|
|
|
GST_START_TEST (test_double_s16)
|
2005-08-20 18:07:10 +00:00
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
2005-10-11 01:37:11 +00:00
|
|
|
GstCaps *caps;
|
2005-08-20 18:07:10 +00:00
|
|
|
gint16 in[2] = { 16384, -256 };
|
|
|
|
gint16 out[2] = { 32767, -512 }; /* notice the clamped sample */
|
2023-07-19 17:25:37 +00:00
|
|
|
gint16 *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2005-08-20 18:07:10 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
2005-09-02 15:43:18 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
2005-08-20 18:07:10 +00:00
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (4);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 4);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2005-10-11 01:37:11 +00:00
|
|
|
gst_caps_unref (caps);
|
2005-08-20 18:07:10 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
2005-08-20 20:40:25 +00:00
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
2005-08-20 18:07:10 +00:00
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
2005-08-29 11:37:20 +00:00
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
2005-08-20 18:07:10 +00:00
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2023-07-19 17:25:37 +00:00
|
|
|
res = (gint16 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], res[0], res[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
fail_unless (memcmp (map.data, out, 4) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2005-08-20 18:07:10 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2011-05-31 09:05:03 +00:00
|
|
|
GST_START_TEST (test_ten_s16)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint16 in[2] = { 16384, -10 };
|
|
|
|
gint16 out[2] = { 32767, -100 }; /* notice the clamped sample */
|
2023-07-19 17:25:37 +00:00
|
|
|
gint16 *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2011-05-31 09:05:03 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 10.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (4);
|
2012-01-04 15:41:53 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 4);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 4) == 0);
|
2011-05-31 09:05:03 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2011-05-31 09:05:03 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2023-07-19 17:25:37 +00:00
|
|
|
res = (gint16 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], res[0], res[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
fail_unless (memcmp (map.data, out, 4) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2011-05-31 09:05:03 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
GST_START_TEST (test_fifteen_s16)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint16 in[4] = { 1, -1, G_MAXINT16, G_MININT16 };
|
|
|
|
gint16 out[4] = { 15, -15, G_MAXINT16, G_MININT16 };
|
|
|
|
/* notice the clamped sample */
|
|
|
|
gint16 *res;
|
|
|
|
GstMapInfo map;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 15.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (8);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 8);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 8) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
res = (gint16 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d", out[0],
|
|
|
|
out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
|
|
|
|
fail_unless (memcmp (map.data, out, 8) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_sixteen_s16)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint16 in[4] = { 1, -1, G_MAXINT16, G_MININT16 };
|
|
|
|
gint16 out[4] = { 16, -16, G_MAXINT16, G_MININT16 };
|
|
|
|
/* notice the clamped sample */
|
|
|
|
gint16 *res;
|
|
|
|
GstMapInfo map;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 16.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (8);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 8);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 8) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
res = (gint16 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d", out[0],
|
|
|
|
out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
|
|
|
|
fail_unless (memcmp (map.data, out, 8) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_max_s16)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint16 in[4] = { 1, -1, G_MAXINT16, G_MININT16 };
|
|
|
|
gint16 out[4] = { G_MAXINT16, G_MININT16, G_MAXINT16, G_MININT16 };
|
|
|
|
/* notice the clamped sample */
|
|
|
|
gint16 *res;
|
|
|
|
GstMapInfo map;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", G_MAXDOUBLE, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (8);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 8);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 8) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
res = (gint16 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d", out[0],
|
|
|
|
out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
|
|
|
|
fail_unless (memcmp (map.data, out, 8) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
gst/adder/gstadder.c: Make it easier to copy&paste
Original commit message from CVS:
* gst/adder/gstadder.c: (gst_adder_get_type):
Make it easier to copy&paste
* gst/volume/Makefile.am:
* gst/volume/gstvolume.c: (volume_update_real_volume),
(gst_volume_set_volume), (gst_volume_set_mute),
(gst_volume_class_init), (volume_process_int16), (volume_set_caps),
(volume_transform_ip), (volume_update_mute),
(volume_update_volume):
* gst/volume/gstvolume.h:
Add own debug category, move duplicate code to helper function, fix
property texts, add more comments and prepare ffor liboil-goodness
* tests/check/Makefile.am:
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
add test for mute and passtrough case, be a bit more verbose to track
failure
* tests/check/generic/states.c: (GST_START_TEST):
catch elements that fail to instantiate
2006-05-28 19:42:27 +00:00
|
|
|
|
2007-09-05 21:20:12 +00:00
|
|
|
GST_START_TEST (test_mute_s16)
|
gst/adder/gstadder.c: Make it easier to copy&paste
Original commit message from CVS:
* gst/adder/gstadder.c: (gst_adder_get_type):
Make it easier to copy&paste
* gst/volume/Makefile.am:
* gst/volume/gstvolume.c: (volume_update_real_volume),
(gst_volume_set_volume), (gst_volume_set_mute),
(gst_volume_class_init), (volume_process_int16), (volume_set_caps),
(volume_transform_ip), (volume_update_mute),
(volume_update_volume):
* gst/volume/gstvolume.h:
Add own debug category, move duplicate code to helper function, fix
property texts, add more comments and prepare ffor liboil-goodness
* tests/check/Makefile.am:
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
add test for mute and passtrough case, be a bit more verbose to track
failure
* tests/check/generic/states.c: (GST_START_TEST):
catch elements that fail to instantiate
2006-05-28 19:42:27 +00:00
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint16 in[2] = { 16384, -256 };
|
|
|
|
gint16 out[2] = { 0, 0 };
|
2023-07-19 17:25:37 +00:00
|
|
|
gint16 *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
gst/adder/gstadder.c: Make it easier to copy&paste
Original commit message from CVS:
* gst/adder/gstadder.c: (gst_adder_get_type):
Make it easier to copy&paste
* gst/volume/Makefile.am:
* gst/volume/gstvolume.c: (volume_update_real_volume),
(gst_volume_set_volume), (gst_volume_set_mute),
(gst_volume_class_init), (volume_process_int16), (volume_set_caps),
(volume_transform_ip), (volume_update_mute),
(volume_update_volume):
* gst/volume/gstvolume.h:
Add own debug category, move duplicate code to helper function, fix
property texts, add more comments and prepare ffor liboil-goodness
* tests/check/Makefile.am:
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
add test for mute and passtrough case, be a bit more verbose to track
failure
* tests/check/generic/states.c: (GST_START_TEST):
catch elements that fail to instantiate
2006-05-28 19:42:27 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "mute", TRUE, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (4);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 4);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
gst/adder/gstadder.c: Make it easier to copy&paste
Original commit message from CVS:
* gst/adder/gstadder.c: (gst_adder_get_type):
Make it easier to copy&paste
* gst/volume/Makefile.am:
* gst/volume/gstvolume.c: (volume_update_real_volume),
(gst_volume_set_volume), (gst_volume_set_mute),
(gst_volume_class_init), (volume_process_int16), (volume_set_caps),
(volume_transform_ip), (volume_update_mute),
(volume_update_volume):
* gst/volume/gstvolume.h:
Add own debug category, move duplicate code to helper function, fix
property texts, add more comments and prepare ffor liboil-goodness
* tests/check/Makefile.am:
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
add test for mute and passtrough case, be a bit more verbose to track
failure
* tests/check/generic/states.c: (GST_START_TEST):
catch elements that fail to instantiate
2006-05-28 19:42:27 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2023-07-19 17:25:37 +00:00
|
|
|
res = (gint16 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], res[0], res[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
fail_unless (memcmp (map.data, out, 4) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
gst/adder/gstadder.c: Make it easier to copy&paste
Original commit message from CVS:
* gst/adder/gstadder.c: (gst_adder_get_type):
Make it easier to copy&paste
* gst/volume/Makefile.am:
* gst/volume/gstvolume.c: (volume_update_real_volume),
(gst_volume_set_volume), (gst_volume_set_mute),
(gst_volume_class_init), (volume_process_int16), (volume_set_caps),
(volume_transform_ip), (volume_update_mute),
(volume_update_volume):
* gst/volume/gstvolume.h:
Add own debug category, move duplicate code to helper function, fix
property texts, add more comments and prepare ffor liboil-goodness
* tests/check/Makefile.am:
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
add test for mute and passtrough case, be a bit more verbose to track
failure
* tests/check/generic/states.c: (GST_START_TEST):
catch elements that fail to instantiate
2006-05-28 19:42:27 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2007-09-05 21:20:12 +00:00
|
|
|
#if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
|
|
|
|
#define get_unaligned_i24(_x) ( (((guint8*)_x)[0]) | ((((guint8*)_x)[1]) << 8) | ((((gint8*)_x)[2]) << 16) )
|
|
|
|
#define write_unaligned_u24(_x,samp) do { (((guint8*)_x)[0]) = samp & 0xFF; (((guint8*)_x)[1]) = (samp >> 8) & 0xFF; (((guint8*)_x)[2]) = (samp >> 16) & 0xFF; } while (0)
|
|
|
|
#else /* BIG ENDIAN */
|
|
|
|
#define get_unaligned_i24(_x) ( (((guint8*)_x)[2]) | ((((guint8*)_x)[1]) << 8) | ((((gint8*)_x)[0]) << 16) )
|
|
|
|
#define write_unaligned_u24(_x,samp) do { (((guint8*)_x)[0]) = (samp >> 16) & 0xFF; (((guint8*)_x)[1]) = (samp >> 8) & 0xFF; (((guint8*)_x)[2]) = samp & 0xFF; } while (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
GST_START_TEST (test_unity_s24)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint32 in_32[2] = { 4194304, -4096 };
|
|
|
|
guint8 in[6];
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
gint32 res_32[2];
|
|
|
|
|
|
|
|
write_unaligned_u24 (in, in_32[0]);
|
|
|
|
write_unaligned_u24 (in + 3, in_32[1]);
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (6);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 6);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
2012-01-20 15:11:54 +00:00
|
|
|
res_32[0] = get_unaligned_i24 (map.data);
|
|
|
|
res_32[1] = get_unaligned_i24 ((map.data + 3));
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", in_32[0], in_32[1], res_32[0],
|
|
|
|
res_32[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
fail_unless (memcmp (map.data, in, 6) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_half_s24)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint32 in_32[2] = { 4194304, -4096 };
|
|
|
|
guint8 in[6];
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
gint32 res_32[2];
|
|
|
|
gint32 out_32[2] = { 2097152, -2048 };
|
|
|
|
|
|
|
|
write_unaligned_u24 (in, in_32[0]);
|
|
|
|
write_unaligned_u24 (in + 3, in_32[1]);
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (6);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 6);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
2012-01-20 15:11:54 +00:00
|
|
|
res_32[0] = get_unaligned_i24 (map.data);
|
|
|
|
res_32[1] = get_unaligned_i24 ((map.data + 3));
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", out_32[0], out_32[1],
|
|
|
|
res_32[0], res_32[1]);
|
|
|
|
fail_unless (memcmp (res_32, out_32, 8) == 0);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_double_s24)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint32 in_32[2] = { 4194304, -4096 };
|
|
|
|
guint8 in[6];
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
gint32 res_32[2];
|
|
|
|
gint32 out_32[2] = { 8388607, -8192 }; /* notice the clamped sample */
|
|
|
|
|
|
|
|
write_unaligned_u24 (in, in_32[0]);
|
|
|
|
write_unaligned_u24 (in + 3, in_32[1]);
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (6);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 6);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
2012-01-20 15:11:54 +00:00
|
|
|
res_32[0] = get_unaligned_i24 (map.data);
|
|
|
|
res_32[1] = get_unaligned_i24 ((map.data + 3));
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", out_32[0], out_32[1],
|
|
|
|
res_32[0], res_32[1]);
|
|
|
|
fail_unless (memcmp (res_32, out_32, 8) == 0);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2011-05-31 09:05:03 +00:00
|
|
|
GST_START_TEST (test_ten_s24)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint32 in_32[2] = { 4194304, -10 };
|
|
|
|
guint8 in[6];
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2011-05-31 09:05:03 +00:00
|
|
|
gint32 res_32[2];
|
|
|
|
gint32 out_32[2] = { 8388607, -100 }; /* notice the clamped sample */
|
|
|
|
|
|
|
|
write_unaligned_u24 (in, in_32[0]);
|
|
|
|
write_unaligned_u24 (in + 3, in_32[1]);
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 10.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (6);
|
2012-01-04 15:41:53 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 6);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 6) == 0);
|
2011-05-31 09:05:03 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2011-05-31 09:05:03 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2011-05-31 09:05:03 +00:00
|
|
|
|
2012-01-20 15:11:54 +00:00
|
|
|
res_32[0] = get_unaligned_i24 (map.data);
|
|
|
|
res_32[1] = get_unaligned_i24 ((map.data + 3));
|
2011-05-31 09:05:03 +00:00
|
|
|
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", out_32[0], out_32[1],
|
|
|
|
res_32[0], res_32[1]);
|
|
|
|
fail_unless (memcmp (res_32, out_32, 8) == 0);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2011-05-31 09:05:03 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
GST_START_TEST (test_fifteen_s24)
|
2007-09-05 21:20:12 +00:00
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
gint32 in_32[4] = { 1, -1, 8388607, -8388608 };
|
|
|
|
guint8 in[12];
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
gint32 res_32[4];
|
|
|
|
gint32 out_32[4] = { 15, -15, 8388607, -8388608 };
|
|
|
|
/* notice the clamped sample */
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
write_unaligned_u24 (in, in_32[0]);
|
|
|
|
write_unaligned_u24 (in + 3, in_32[1]);
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
write_unaligned_u24 (in + 6, in_32[2]);
|
|
|
|
write_unaligned_u24 (in + 9, in_32[3]);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
g_object_set (G_OBJECT (volume), "volume", 15.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
2007-09-05 21:20:12 +00:00
|
|
|
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
inbuffer = gst_buffer_new_and_alloc (12);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 12);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
2012-01-20 15:11:54 +00:00
|
|
|
res_32[0] = get_unaligned_i24 (map.data);
|
|
|
|
res_32[1] = get_unaligned_i24 ((map.data + 3));
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
res_32[2] = get_unaligned_i24 ((map.data + 6));
|
|
|
|
res_32[3] = get_unaligned_i24 ((map.data + 9));
|
2007-09-05 21:20:12 +00:00
|
|
|
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d", out_32[0],
|
|
|
|
out_32[1], out_32[2], out_32[3], res_32[0], res_32[1], res_32[2],
|
|
|
|
res_32[3]);
|
|
|
|
fail_unless (memcmp (res_32, out_32, 16) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_sixteen_s24)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint32 in_32[4] = { 1, -1, 8388607, -8388608 };
|
|
|
|
guint8 in[12];
|
|
|
|
GstMapInfo map;
|
|
|
|
gint32 res_32[4];
|
|
|
|
gint32 out_32[4] = { 16, -16, 8388607, -8388608 };
|
|
|
|
/* notice the clamped sample */
|
|
|
|
|
|
|
|
write_unaligned_u24 (in, in_32[0]);
|
|
|
|
write_unaligned_u24 (in + 3, in_32[1]);
|
|
|
|
write_unaligned_u24 (in + 6, in_32[2]);
|
|
|
|
write_unaligned_u24 (in + 9, in_32[3]);
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 16.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (12);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 12);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
|
|
|
|
res_32[0] = get_unaligned_i24 (map.data);
|
|
|
|
res_32[1] = get_unaligned_i24 ((map.data + 3));
|
|
|
|
res_32[2] = get_unaligned_i24 ((map.data + 6));
|
|
|
|
res_32[3] = get_unaligned_i24 ((map.data + 9));
|
|
|
|
|
|
|
|
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d", out_32[0],
|
|
|
|
out_32[1], out_32[2], out_32[3], res_32[0], res_32[1], res_32[2],
|
|
|
|
res_32[3]);
|
|
|
|
fail_unless (memcmp (res_32, out_32, 16) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_4095_s24)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint32 in_32[4] = { 1, -1, 8388607, -8388608 };
|
|
|
|
guint8 in[12];
|
|
|
|
GstMapInfo map;
|
|
|
|
gint32 res_32[4];
|
|
|
|
gint32 out_32[4] = { 4095, -4095, 8388607, -8388608 };
|
|
|
|
/* notice the clamped sample */
|
|
|
|
|
|
|
|
write_unaligned_u24 (in, in_32[0]);
|
|
|
|
write_unaligned_u24 (in + 3, in_32[1]);
|
|
|
|
write_unaligned_u24 (in + 6, in_32[2]);
|
|
|
|
write_unaligned_u24 (in + 9, in_32[3]);
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 4095.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (12);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 12);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
|
|
|
|
res_32[0] = get_unaligned_i24 (map.data);
|
|
|
|
res_32[1] = get_unaligned_i24 ((map.data + 3));
|
|
|
|
res_32[2] = get_unaligned_i24 ((map.data + 6));
|
|
|
|
res_32[3] = get_unaligned_i24 ((map.data + 9));
|
|
|
|
|
|
|
|
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d", out_32[0],
|
|
|
|
out_32[1], out_32[2], out_32[3], res_32[0], res_32[1], res_32[2],
|
|
|
|
res_32[3]);
|
|
|
|
fail_unless (memcmp (res_32, out_32, 16) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_4096_s24)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint32 in_32[4] = { 1, -1, 8388607, -8388608 };
|
|
|
|
guint8 in[12];
|
|
|
|
GstMapInfo map;
|
|
|
|
gint32 res_32[4];
|
|
|
|
gint32 out_32[4] = { 4096, -4096, 8388607, -8388608 };
|
|
|
|
/* notice the clamped sample */
|
|
|
|
|
|
|
|
write_unaligned_u24 (in, in_32[0]);
|
|
|
|
write_unaligned_u24 (in + 3, in_32[1]);
|
|
|
|
write_unaligned_u24 (in + 6, in_32[2]);
|
|
|
|
write_unaligned_u24 (in + 9, in_32[3]);
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 4096.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (12);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 12);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
|
|
|
|
res_32[0] = get_unaligned_i24 (map.data);
|
|
|
|
res_32[1] = get_unaligned_i24 ((map.data + 3));
|
|
|
|
res_32[2] = get_unaligned_i24 ((map.data + 6));
|
|
|
|
res_32[3] = get_unaligned_i24 ((map.data + 9));
|
|
|
|
|
|
|
|
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d", out_32[0],
|
|
|
|
out_32[1], out_32[2], out_32[3], res_32[0], res_32[1], res_32[2],
|
|
|
|
res_32[3]);
|
|
|
|
fail_unless (memcmp (res_32, out_32, 16) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_max_s24)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint32 in_32[4] = { 1, -1, 8388607, -8388608 };
|
|
|
|
guint8 in[12];
|
|
|
|
GstMapInfo map;
|
|
|
|
gint32 res_32[4];
|
|
|
|
gint32 out_32[4] = { 8388607, -8388608, 8388607, -8388608 };
|
|
|
|
/* notice the clamped sample */
|
|
|
|
|
|
|
|
write_unaligned_u24 (in, in_32[0]);
|
|
|
|
write_unaligned_u24 (in + 3, in_32[1]);
|
|
|
|
write_unaligned_u24 (in + 6, in_32[2]);
|
|
|
|
write_unaligned_u24 (in + 9, in_32[3]);
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", G_MAXDOUBLE, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (12);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 12);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
|
|
|
|
res_32[0] = get_unaligned_i24 (map.data);
|
|
|
|
res_32[1] = get_unaligned_i24 ((map.data + 3));
|
|
|
|
res_32[2] = get_unaligned_i24 ((map.data + 6));
|
|
|
|
res_32[3] = get_unaligned_i24 ((map.data + 9));
|
|
|
|
|
|
|
|
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d", out_32[0],
|
|
|
|
out_32[1], out_32[2], out_32[3], res_32[0], res_32[1], res_32[2],
|
|
|
|
res_32[3]);
|
|
|
|
fail_unless (memcmp (res_32, out_32, 16) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_mute_s24)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint32 in_32[2] = { 4194304, -4096 };
|
|
|
|
guint8 in[6];
|
|
|
|
GstMapInfo map;
|
|
|
|
gint32 res_32[2];
|
|
|
|
gint32 out_32[2] = { 0, 0 }; /* notice the clamped sample */
|
|
|
|
|
|
|
|
write_unaligned_u24 (in, in_32[0]);
|
|
|
|
write_unaligned_u24 (in + 3, in_32[1]);
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "mute", TRUE, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (6);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 6);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S24);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
|
|
|
|
res_32[0] = get_unaligned_i24 (map.data);
|
|
|
|
res_32[1] = get_unaligned_i24 ((map.data + 3));
|
|
|
|
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", out_32[0], out_32[1],
|
|
|
|
res_32[0], res_32[1]);
|
2007-09-05 21:20:12 +00:00
|
|
|
fail_unless (memcmp (res_32, out_32, 8) == 0);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_unity_s32)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint32 in[2] = { 1073741824, -65536 };
|
2023-07-19 17:25:37 +00:00
|
|
|
gint32 *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (8);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 8);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2023-07-19 17:25:37 +00:00
|
|
|
res = (gint32 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], res[0], res[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
fail_unless (memcmp (map.data, in, 8) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_half_s32)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint32 in[2] = { 1073741824, -65536 };
|
|
|
|
gint32 out[2] = { 536870912, -32768 };
|
2023-07-19 17:25:37 +00:00
|
|
|
gint32 *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (8);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 8);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2023-07-19 17:25:37 +00:00
|
|
|
res = (gint32 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], res[0], res[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
fail_unless (memcmp (map.data, out, 8) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_double_s32)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint32 in[2] = { 1073741824, -65536 };
|
|
|
|
gint32 out[2] = { 2147483647, -131072 }; /* notice the clamped sample */
|
2023-07-19 17:25:37 +00:00
|
|
|
gint32 *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (8);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 8);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2023-07-19 17:25:37 +00:00
|
|
|
res = (gint32 *) map.data;
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], res[0], res[1]);
|
|
|
|
fail_unless (memcmp (map.data, out, 8) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_ten_s32)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint32 in[2] = { 1073741824, -10 };
|
|
|
|
gint32 out[2] = { 2147483647, -100 }; /* notice the clamped sample */
|
|
|
|
gint32 *res;
|
|
|
|
GstMapInfo map;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 10.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (8);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 8);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 8) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
res = (gint32 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], res[0], res[1]);
|
|
|
|
fail_unless (memcmp (map.data, out, 8) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_fifteen_s32)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint32 in[4] = { 1, -1, G_MAXINT32, G_MININT32 };
|
|
|
|
gint32 out[4] = { 15, -15, G_MAXINT32, G_MININT32 };
|
|
|
|
/* notice the clamped sample */
|
|
|
|
gint32 *res;
|
|
|
|
GstMapInfo map;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 15.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (16);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 16);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
res = (gint32 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d", out[0],
|
|
|
|
out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
|
|
|
|
fail_unless (memcmp (map.data, out, 16) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_sixteen_s32)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint32 in[4] = { 1, -1, G_MAXINT32, G_MININT32 };
|
|
|
|
gint32 out[4] = { 16, -16, G_MAXINT32, G_MININT32 };
|
|
|
|
/* notice the clamped sample */
|
|
|
|
gint32 *res;
|
|
|
|
GstMapInfo map;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 16.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (16);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 16);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
res = (gint32 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d", out[0],
|
|
|
|
out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
|
|
|
|
fail_unless (memcmp (map.data, out, 16) == 0);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
GST_START_TEST (test_max_s32)
|
2011-05-31 09:05:03 +00:00
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
gint32 in[4] = { 1, -1, G_MAXINT32, G_MININT32 };
|
|
|
|
gint32 out[4] = { G_MAXINT32, G_MININT32, G_MAXINT32, G_MININT32 };
|
|
|
|
/* notice the clamped sample */
|
2023-07-19 17:25:37 +00:00
|
|
|
gint32 *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2011-05-31 09:05:03 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
g_object_set (G_OBJECT (volume), "volume", G_MAXDOUBLE, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
2011-05-31 09:05:03 +00:00
|
|
|
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
inbuffer = gst_buffer_new_and_alloc (16);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 16);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
|
2011-05-31 09:05:03 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2011-05-31 09:05:03 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2023-07-19 17:25:37 +00:00
|
|
|
res = (gint32 *) map.data;
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
GST_INFO ("expected %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d", out[0],
|
|
|
|
out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
|
|
|
|
fail_unless (memcmp (map.data, out, 16) == 0);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2011-05-31 09:05:03 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
GST_START_TEST (test_mute_s32)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gint32 in[2] = { 1073741824, -65536 };
|
|
|
|
gint32 out[2] = { 0, 0 };
|
2023-07-19 17:25:37 +00:00
|
|
|
gint32 *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "mute", TRUE, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (8);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 8);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S32);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2023-07-19 17:25:37 +00:00
|
|
|
res = (gint32 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], res[0], res[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
fail_unless (memcmp (map.data, out, 8) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_unity_f32)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
2012-02-03 14:01:50 +00:00
|
|
|
gfloat in[2] = { 0.75, -0.25 }, *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (8);
|
2012-02-03 14:01:50 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, sizeof (in));
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2012-02-03 14:01:50 +00:00
|
|
|
res = (gfloat *) map.data;
|
2012-01-20 15:11:54 +00:00
|
|
|
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", in[0], in[1],
|
2012-02-03 14:01:50 +00:00
|
|
|
res[0], res[1]);
|
|
|
|
fail_unless_equals_float (res[0], in[0]);
|
|
|
|
fail_unless_equals_float (res[1], in[1]);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_half_f32)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gfloat in[2] = { 0.75, -0.25 };
|
|
|
|
gfloat out[2] = { 0.375, -0.125 };
|
2012-02-03 14:01:50 +00:00
|
|
|
gfloat *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (8);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 8);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2012-02-03 14:01:50 +00:00
|
|
|
res = (gfloat *) map.data;
|
2007-09-05 21:20:12 +00:00
|
|
|
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
|
2012-02-03 14:01:50 +00:00
|
|
|
res[0], res[1]);
|
|
|
|
fail_unless_equals_float (res[0], out[0]);
|
|
|
|
fail_unless_equals_float (res[1], out[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_double_f32)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gfloat in[2] = { 0.75, -0.25 };
|
2007-09-09 04:08:48 +00:00
|
|
|
gfloat out[2] = { 1.5, -0.5 }; /* nothing is clamped */
|
2012-02-03 14:01:50 +00:00
|
|
|
gfloat *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (8);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 8);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2012-02-03 14:01:50 +00:00
|
|
|
res = (gfloat *) map.data;
|
2007-09-05 21:20:12 +00:00
|
|
|
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
|
2012-02-03 14:01:50 +00:00
|
|
|
res[0], res[1]);
|
|
|
|
fail_unless_equals_float (res[0], out[0]);
|
|
|
|
fail_unless_equals_float (res[1], out[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2011-05-31 09:05:03 +00:00
|
|
|
GST_START_TEST (test_ten_f32)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gfloat in[2] = { 0.75, -0.25 };
|
|
|
|
gfloat out[2] = { 7.5, -2.5 }; /* nothing is clamped */
|
2012-02-03 14:01:50 +00:00
|
|
|
gfloat *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2011-05-31 09:05:03 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 10.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (8);
|
2012-01-04 15:41:53 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 8);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 8) == 0);
|
2011-05-31 09:05:03 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2011-05-31 09:05:03 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2012-02-03 14:01:50 +00:00
|
|
|
res = (gfloat *) map.data;
|
2011-05-31 09:05:03 +00:00
|
|
|
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
|
2012-02-03 14:01:50 +00:00
|
|
|
res[0], res[1]);
|
|
|
|
fail_unless_equals_float (res[0], out[0]);
|
|
|
|
fail_unless_equals_float (res[1], out[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2011-05-31 09:05:03 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
GST_START_TEST (test_fifteen_f32)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gfloat in[4] = { 1.0, -1.0, 2.0, -2.0 };
|
|
|
|
gfloat out[4] = { 15.0, -15.0, 30.0, -30.0 }; /* nothing is clamped */
|
|
|
|
gfloat *res;
|
|
|
|
GstMapInfo map;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 15.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (16);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 16);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
res = (gfloat *) map.data;
|
|
|
|
GST_INFO
|
|
|
|
("expected %+1.4f %+1.4f %+1.4f %+1.4f real %+1.4f %+1.4f %+1.4f %+1.4f",
|
|
|
|
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
|
|
|
|
fail_unless_equals_float (res[0], out[0]);
|
|
|
|
fail_unless_equals_float (res[1], out[1]);
|
|
|
|
fail_unless_equals_float (res[2], out[2]);
|
|
|
|
fail_unless_equals_float (res[3], out[3]);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_sixteen_f32)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gfloat in[4] = { 1.0, -1.0, 2.0, -2.0 };
|
|
|
|
gfloat out[4] = { 16.0, -16.0, 32.0, -32.0 }; /* nothing is clamped */
|
|
|
|
gfloat *res;
|
|
|
|
GstMapInfo map;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 16.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (16);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 16);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
res = (gfloat *) map.data;
|
|
|
|
GST_INFO
|
|
|
|
("expected %+1.4f %+1.4f %+1.4f %+1.4f real %+1.4f %+1.4f %+1.4f %+1.4f",
|
|
|
|
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
|
|
|
|
fail_unless_equals_float (res[0], out[0]);
|
|
|
|
fail_unless_equals_float (res[1], out[1]);
|
|
|
|
fail_unless_equals_float (res[2], out[2]);
|
|
|
|
fail_unless_equals_float (res[3], out[3]);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_max_f32)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gfloat in[4] = { 1.0, -1.0, 2.0, -2.0 };
|
|
|
|
gfloat out[4] = { INFINITY, -INFINITY, INFINITY,
|
|
|
|
-INFINITY
|
|
|
|
}; /* nothing is clamped */
|
|
|
|
gfloat *res;
|
|
|
|
GstMapInfo map;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", G_MAXDOUBLE, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (16);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 16);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
res = (gfloat *) map.data;
|
|
|
|
GST_INFO
|
|
|
|
("expected %+1.4f %+1.4f %+1.4f %+1.4f real %+1.4f %+1.4f %+1.4f %+1.4f",
|
|
|
|
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
|
|
|
|
fail_unless (memcmp (map.data, out, 16) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
GST_START_TEST (test_mute_f32)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gfloat in[2] = { 0.75, -0.25 };
|
|
|
|
gfloat out[2] = { 0, 0 };
|
2012-02-03 14:01:50 +00:00
|
|
|
gfloat *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "mute", TRUE, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (8);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 8);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F32);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2012-02-03 14:01:50 +00:00
|
|
|
res = (gfloat *) map.data;
|
2007-09-05 21:20:12 +00:00
|
|
|
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
|
2012-02-03 14:01:50 +00:00
|
|
|
res[0], res[1]);
|
|
|
|
fail_unless_equals_float (res[0], out[0]);
|
|
|
|
fail_unless_equals_float (res[1], out[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_unity_f64)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gdouble in[2] = { 0.75, -0.25 };
|
2012-02-03 14:01:50 +00:00
|
|
|
gdouble *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (16);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 16);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2012-02-03 14:01:50 +00:00
|
|
|
res = (gdouble *) map.data;
|
2012-01-20 15:11:54 +00:00
|
|
|
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", in[0], in[1],
|
2012-02-03 14:01:50 +00:00
|
|
|
res[0], res[1]);
|
|
|
|
fail_unless_equals_float (res[0], in[0]);
|
|
|
|
fail_unless_equals_float (res[1], in[1]);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_half_f64)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gdouble in[2] = { 0.75, -0.25 };
|
|
|
|
gdouble out[2] = { 0.375, -0.125 };
|
2012-02-03 14:01:50 +00:00
|
|
|
gdouble *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 0.5, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (16);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 16);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2012-02-03 14:01:50 +00:00
|
|
|
res = (gdouble *) map.data;
|
2007-09-05 21:20:12 +00:00
|
|
|
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
|
2012-02-03 14:01:50 +00:00
|
|
|
res[0], res[1]);
|
|
|
|
fail_unless_equals_float (res[0], out[0]);
|
|
|
|
fail_unless_equals_float (res[1], out[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_double_f64)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gdouble in[2] = { 0.75, -0.25 };
|
2007-09-09 04:08:48 +00:00
|
|
|
gdouble out[2] = { 1.5, -0.5 }; /* nothing is clamped */
|
2012-02-03 14:01:50 +00:00
|
|
|
gdouble *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 2.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (16);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 16);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2012-02-03 14:01:50 +00:00
|
|
|
res = (gdouble *) map.data;
|
2007-09-05 21:20:12 +00:00
|
|
|
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
|
2012-02-03 14:01:50 +00:00
|
|
|
res[0], res[1]);
|
|
|
|
fail_unless_equals_float (res[0], out[0]);
|
|
|
|
fail_unless_equals_float (res[1], out[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2011-05-31 09:05:03 +00:00
|
|
|
GST_START_TEST (test_ten_f64)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gdouble in[2] = { 0.75, -0.25 };
|
|
|
|
gdouble out[2] = { 7.5, -2.5 }; /* nothing is clamped */
|
2012-02-03 14:01:50 +00:00
|
|
|
gdouble *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2011-05-31 09:05:03 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 10.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (16);
|
2012-01-04 15:41:53 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 16);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
|
2011-05-31 09:05:03 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2011-05-31 09:05:03 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2012-02-03 14:01:50 +00:00
|
|
|
res = (gdouble *) map.data;
|
2011-05-31 09:05:03 +00:00
|
|
|
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
|
2012-02-03 14:01:50 +00:00
|
|
|
res[0], res[1]);
|
|
|
|
fail_unless_equals_float (res[0], out[0]);
|
|
|
|
fail_unless_equals_float (res[1], out[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2011-05-31 09:05:03 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
GST_START_TEST (test_fifteen_f64)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gdouble in[4] = { 1.0, -1.0, 2.0, -2.0 };
|
|
|
|
gdouble out[4] = { 15.0, -15.0, 30.0, -30.0 }; /* nothing is clamped */
|
|
|
|
gdouble *res;
|
|
|
|
GstMapInfo map;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 15.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (32);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 32);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 32) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
res = (gdouble *) map.data;
|
|
|
|
GST_INFO
|
|
|
|
("expected %+1.4f %+1.4f %+1.4f %+1.4f real %+1.4f %+1.4f %+1.4f %+1.4f",
|
|
|
|
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
|
|
|
|
fail_unless_equals_float (res[0], out[0]);
|
|
|
|
fail_unless_equals_float (res[1], out[1]);
|
|
|
|
fail_unless_equals_float (res[2], out[2]);
|
|
|
|
fail_unless_equals_float (res[3], out[3]);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_sixteen_f64)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gdouble in[4] = { 1.0, -1.0, 2.0, -2.0 };
|
|
|
|
gdouble out[4] = { 16.0, -16.0, 32.0, -32.0 }; /* nothing is clamped */
|
|
|
|
gdouble *res;
|
|
|
|
GstMapInfo map;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", 16.0, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (32);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 32);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 32) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
res = (gdouble *) map.data;
|
|
|
|
GST_INFO
|
|
|
|
("expected %+1.4f %+1.4f %+1.4f %+1.4f real %+1.4f %+1.4f %+1.4f %+1.4f",
|
|
|
|
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
|
|
|
|
fail_unless_equals_float (res[0], out[0]);
|
|
|
|
fail_unless_equals_float (res[1], out[1]);
|
|
|
|
fail_unless_equals_float (res[2], out[2]);
|
|
|
|
fail_unless_equals_float (res[3], out[3]);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
|
|
|
GST_START_TEST (test_max_f64)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gdouble in[4] = { 1.0, -1.0, 2.0, -2.0 };
|
|
|
|
gdouble out[4] = { INFINITY, -INFINITY, INFINITY,
|
|
|
|
-INFINITY
|
|
|
|
}; /* nothing is clamped */
|
|
|
|
gdouble *res;
|
|
|
|
GstMapInfo map;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "volume", G_MAXDOUBLE, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume, GST_STATE_PLAYING) ==
|
|
|
|
GST_STATE_CHANGE_SUCCESS, "could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (32);
|
|
|
|
gst_buffer_fill (inbuffer, 0, in, 32);
|
|
|
|
fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 32) == 0);
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
|
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
|
|
|
res = (gdouble *) map.data;
|
|
|
|
GST_INFO
|
|
|
|
("expected %+1.4f %+1.4f %+1.4f %+1.4f real %+1.4f %+1.4f %+1.4f %+1.4f",
|
|
|
|
out[0], out[1], out[2], out[3], res[0], res[1], res[2], res[3]);
|
|
|
|
fail_unless (memcmp (map.data, out, 32) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
GST_START_TEST (test_mute_f64)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstBuffer *outbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
gdouble in[2] = { 0.75, -0.25 };
|
|
|
|
gdouble out[2] = { 0, 0 };
|
2012-02-03 14:01:50 +00:00
|
|
|
gdouble *res;
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
g_object_set (G_OBJECT (volume), "mute", TRUE, NULL);
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (16);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 16);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_F64);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2007-09-05 21:20:12 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
/* FIXME: reffing the inbuffer should make the transformation not be
|
|
|
|
* inplace
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being modified inplace and
|
|
|
|
* collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2012-02-03 14:01:50 +00:00
|
|
|
res = (gdouble *) map.data;
|
2007-09-05 21:20:12 +00:00
|
|
|
GST_INFO ("expected %+1.4f %+1.4f real %+1.4f %+1.4f", out[0], out[1],
|
2012-02-03 14:01:50 +00:00
|
|
|
res[0], res[1]);
|
|
|
|
fail_unless_equals_float (res[0], out[0]);
|
|
|
|
fail_unless_equals_float (res[1], out[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
2007-09-05 21:20:12 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
gst/adder/gstadder.c: Make it easier to copy&paste
Original commit message from CVS:
* gst/adder/gstadder.c: (gst_adder_get_type):
Make it easier to copy&paste
* gst/volume/Makefile.am:
* gst/volume/gstvolume.c: (volume_update_real_volume),
(gst_volume_set_volume), (gst_volume_set_mute),
(gst_volume_class_init), (volume_process_int16), (volume_set_caps),
(volume_transform_ip), (volume_update_mute),
(volume_update_volume):
* gst/volume/gstvolume.h:
Add own debug category, move duplicate code to helper function, fix
property texts, add more comments and prepare ffor liboil-goodness
* tests/check/Makefile.am:
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
add test for mute and passtrough case, be a bit more verbose to track
failure
* tests/check/generic/states.c: (GST_START_TEST):
catch elements that fail to instantiate
2006-05-28 19:42:27 +00:00
|
|
|
|
2005-08-20 20:40:25 +00:00
|
|
|
GST_START_TEST (test_wrong_caps)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
2006-09-16 22:30:50 +00:00
|
|
|
GstBuffer *inbuffer;
|
2005-08-20 20:40:25 +00:00
|
|
|
gint16 in[2] = { 16384, -256 };
|
|
|
|
GstBus *bus;
|
|
|
|
GstMessage *message;
|
2005-10-11 01:37:11 +00:00
|
|
|
GstCaps *caps;
|
2005-08-20 20:40:25 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
bus = gst_bus_new ();
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
2005-09-02 15:43:18 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
2005-08-20 20:40:25 +00:00
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (4);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 4);
|
2005-10-11 01:37:11 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_WRONG_CAPS_STRING);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2005-10-11 01:37:11 +00:00
|
|
|
gst_caps_unref (caps);
|
2005-08-20 20:40:25 +00:00
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
gst_buffer_ref (inbuffer);
|
|
|
|
|
|
|
|
/* set a bus here so we avoid getting state change messages */
|
|
|
|
gst_element_set_bus (volume, bus);
|
|
|
|
|
|
|
|
/* pushing gives an error because it can't negotiate with wrong caps */
|
|
|
|
fail_unless_equals_int (gst_pad_push (mysrcpad, inbuffer),
|
|
|
|
GST_FLOW_NOT_NEGOTIATED);
|
|
|
|
/* ... and the buffer would have been lost if we didn't ref it ourselves */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
gst_buffer_unref (inbuffer);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 0);
|
|
|
|
|
|
|
|
/* volume_set_caps should not have been called since basetransform caught
|
|
|
|
* the negotiation problem */
|
|
|
|
fail_if ((message = gst_bus_pop (bus)) != NULL);
|
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
gst_element_set_bus (volume, NULL);
|
|
|
|
gst_object_unref (GST_OBJECT (bus));
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
gst/adder/gstadder.c: Make it easier to copy&paste
Original commit message from CVS:
* gst/adder/gstadder.c: (gst_adder_get_type):
Make it easier to copy&paste
* gst/volume/Makefile.am:
* gst/volume/gstvolume.c: (volume_update_real_volume),
(gst_volume_set_volume), (gst_volume_set_mute),
(gst_volume_class_init), (volume_process_int16), (volume_set_caps),
(volume_transform_ip), (volume_update_mute),
(volume_update_volume):
* gst/volume/gstvolume.h:
Add own debug category, move duplicate code to helper function, fix
property texts, add more comments and prepare ffor liboil-goodness
* tests/check/Makefile.am:
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
add test for mute and passtrough case, be a bit more verbose to track
failure
* tests/check/generic/states.c: (GST_START_TEST):
catch elements that fail to instantiate
2006-05-28 19:42:27 +00:00
|
|
|
GST_START_TEST (test_passthrough)
|
|
|
|
{
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
2012-04-25 16:42:04 +00:00
|
|
|
gint16 *out, in[2] = { 16384, -256 };
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
gst/adder/gstadder.c: Make it easier to copy&paste
Original commit message from CVS:
* gst/adder/gstadder.c: (gst_adder_get_type):
Make it easier to copy&paste
* gst/volume/Makefile.am:
* gst/volume/gstvolume.c: (volume_update_real_volume),
(gst_volume_set_volume), (gst_volume_set_mute),
(gst_volume_class_init), (volume_process_int16), (volume_set_caps),
(volume_transform_ip), (volume_update_mute),
(volume_update_volume):
* gst/volume/gstvolume.h:
Add own debug category, move duplicate code to helper function, fix
property texts, add more comments and prepare ffor liboil-goodness
* tests/check/Makefile.am:
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
add test for mute and passtrough case, be a bit more verbose to track
failure
* tests/check/generic/states.c: (GST_START_TEST):
catch elements that fail to instantiate
2006-05-28 19:42:27 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
gst/volume/gstvolume.*: Cleanup volume, define and use default values.
Original commit message from CVS:
* gst/volume/gstvolume.c: (volume_choose_func),
(volume_update_volume), (gst_volume_set_volume),
(gst_volume_get_volume), (gst_volume_set_mute),
(gst_volume_class_init), (gst_volume_init),
(volume_process_double), (volume_process_float),
(volume_process_int32), (volume_process_int32_clamp),
(volume_process_int24), (volume_process_int24_clamp),
(volume_process_int16), (volume_process_int16_clamp),
(volume_process_int8), (volume_process_int8_clamp), (volume_setup),
(volume_transform_ip), (volume_set_property),
(volume_get_property):
* gst/volume/gstvolume.h:
Cleanup volume, define and use default values.
Recalculate new volume and mute setup before processing. Fixes #561789.
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
Add controller unit test. Patch by: Jonathan Matthew
Fix bogus test that messed with basetransform's internal state.
2008-11-24 12:03:11 +00:00
|
|
|
g_object_set (G_OBJECT (volume), "volume", 1.0, NULL);
|
gst/adder/gstadder.c: Make it easier to copy&paste
Original commit message from CVS:
* gst/adder/gstadder.c: (gst_adder_get_type):
Make it easier to copy&paste
* gst/volume/Makefile.am:
* gst/volume/gstvolume.c: (volume_update_real_volume),
(gst_volume_set_volume), (gst_volume_set_mute),
(gst_volume_class_init), (volume_process_int16), (volume_set_caps),
(volume_transform_ip), (volume_update_mute),
(volume_update_volume):
* gst/volume/gstvolume.h:
Add own debug category, move duplicate code to helper function, fix
property texts, add more comments and prepare ffor liboil-goodness
* tests/check/Makefile.am:
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
add test for mute and passtrough case, be a bit more verbose to track
failure
* tests/check/generic/states.c: (GST_START_TEST):
catch elements that fail to instantiate
2006-05-28 19:42:27 +00:00
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (4);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 4);
|
2007-09-05 21:20:12 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
gst/adder/gstadder.c: Make it easier to copy&paste
Original commit message from CVS:
* gst/adder/gstadder.c: (gst_adder_get_type):
Make it easier to copy&paste
* gst/volume/Makefile.am:
* gst/volume/gstvolume.c: (volume_update_real_volume),
(gst_volume_set_volume), (gst_volume_set_mute),
(gst_volume_class_init), (volume_process_int16), (volume_set_caps),
(volume_transform_ip), (volume_update_mute),
(volume_update_volume):
* gst/volume/gstvolume.h:
Add own debug category, move duplicate code to helper function, fix
property texts, add more comments and prepare ffor liboil-goodness
* tests/check/Makefile.am:
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
add test for mute and passtrough case, be a bit more verbose to track
failure
* tests/check/generic/states.c: (GST_START_TEST):
catch elements that fail to instantiate
2006-05-28 19:42:27 +00:00
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2012-04-25 16:42:04 +00:00
|
|
|
out = (gint16 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], out[0], out[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
fail_unless (memcmp (map.data, in, 4) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
gst/adder/gstadder.c: Make it easier to copy&paste
Original commit message from CVS:
* gst/adder/gstadder.c: (gst_adder_get_type):
Make it easier to copy&paste
* gst/volume/Makefile.am:
* gst/volume/gstvolume.c: (volume_update_real_volume),
(gst_volume_set_volume), (gst_volume_set_mute),
(gst_volume_class_init), (volume_process_int16), (volume_set_caps),
(volume_transform_ip), (volume_update_mute),
(volume_update_volume):
* gst/volume/gstvolume.h:
Add own debug category, move duplicate code to helper function, fix
property texts, add more comments and prepare ffor liboil-goodness
* tests/check/Makefile.am:
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
add test for mute and passtrough case, be a bit more verbose to track
failure
* tests/check/generic/states.c: (GST_START_TEST):
catch elements that fail to instantiate
2006-05-28 19:42:27 +00:00
|
|
|
|
|
|
|
/* cleanup */
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2007-05-04 12:41:21 +00:00
|
|
|
GST_START_TEST (test_controller_usability)
|
|
|
|
{
|
2012-01-31 11:28:30 +00:00
|
|
|
GstControlSource *cs;
|
|
|
|
GstTimedValueControlSource *tvcs;
|
2012-04-12 13:06:15 +00:00
|
|
|
GstControlBinding *cb;
|
2007-05-04 12:41:21 +00:00
|
|
|
GstElement *volume;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
|
|
|
|
/* this shouldn't crash, whether this mode is implemented or not */
|
2012-01-31 11:28:30 +00:00
|
|
|
cs = gst_interpolation_control_source_new ();
|
|
|
|
g_object_set (cs, "mode", GST_INTERPOLATION_MODE_CUBIC, NULL);
|
2012-04-12 13:06:15 +00:00
|
|
|
cb = gst_direct_control_binding_new (GST_OBJECT_CAST (volume), "volume", cs);
|
|
|
|
gst_object_add_control_binding (GST_OBJECT_CAST (volume), cb);
|
2011-12-30 17:36:37 +00:00
|
|
|
|
2012-01-31 11:28:30 +00:00
|
|
|
tvcs = (GstTimedValueControlSource *) cs;
|
|
|
|
gst_timed_value_control_source_set (tvcs, 0 * GST_SECOND, 0.0);
|
|
|
|
gst_timed_value_control_source_set (tvcs, 5 * GST_SECOND, 1.0);
|
|
|
|
gst_timed_value_control_source_set (tvcs, 10 * GST_SECOND, 0.0);
|
2011-12-30 17:36:37 +00:00
|
|
|
|
2012-01-31 11:28:30 +00:00
|
|
|
gst_object_unref (cs);
|
2012-04-12 13:06:15 +00:00
|
|
|
gst_object_remove_control_binding (GST_OBJECT_CAST (volume), cb);
|
2007-05-04 12:41:21 +00:00
|
|
|
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
gst/volume/gstvolume.*: Cleanup volume, define and use default values.
Original commit message from CVS:
* gst/volume/gstvolume.c: (volume_choose_func),
(volume_update_volume), (gst_volume_set_volume),
(gst_volume_get_volume), (gst_volume_set_mute),
(gst_volume_class_init), (gst_volume_init),
(volume_process_double), (volume_process_float),
(volume_process_int32), (volume_process_int32_clamp),
(volume_process_int24), (volume_process_int24_clamp),
(volume_process_int16), (volume_process_int16_clamp),
(volume_process_int8), (volume_process_int8_clamp), (volume_setup),
(volume_transform_ip), (volume_set_property),
(volume_get_property):
* gst/volume/gstvolume.h:
Cleanup volume, define and use default values.
Recalculate new volume and mute setup before processing. Fixes #561789.
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
Add controller unit test. Patch by: Jonathan Matthew
Fix bogus test that messed with basetransform's internal state.
2008-11-24 12:03:11 +00:00
|
|
|
GST_START_TEST (test_controller_processing)
|
|
|
|
{
|
2012-01-31 11:28:30 +00:00
|
|
|
GstControlSource *cs;
|
2012-04-25 16:43:59 +00:00
|
|
|
GstTimedValueControlSource *tvcs;
|
gst/volume/gstvolume.*: Cleanup volume, define and use default values.
Original commit message from CVS:
* gst/volume/gstvolume.c: (volume_choose_func),
(volume_update_volume), (gst_volume_set_volume),
(gst_volume_get_volume), (gst_volume_set_mute),
(gst_volume_class_init), (gst_volume_init),
(volume_process_double), (volume_process_float),
(volume_process_int32), (volume_process_int32_clamp),
(volume_process_int24), (volume_process_int24_clamp),
(volume_process_int16), (volume_process_int16_clamp),
(volume_process_int8), (volume_process_int8_clamp), (volume_setup),
(volume_transform_ip), (volume_set_property),
(volume_get_property):
* gst/volume/gstvolume.h:
Cleanup volume, define and use default values.
Recalculate new volume and mute setup before processing. Fixes #561789.
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
Add controller unit test. Patch by: Jonathan Matthew
Fix bogus test that messed with basetransform's internal state.
2008-11-24 12:03:11 +00:00
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer, *outbuffer;
|
|
|
|
GstCaps *caps;
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
gint16 *out, in[2] = { +32767, -32768 };
|
2012-01-20 15:11:54 +00:00
|
|
|
GstMapInfo map;
|
2012-02-03 14:01:50 +00:00
|
|
|
GstSegment seg;
|
gst/volume/gstvolume.*: Cleanup volume, define and use default values.
Original commit message from CVS:
* gst/volume/gstvolume.c: (volume_choose_func),
(volume_update_volume), (gst_volume_set_volume),
(gst_volume_get_volume), (gst_volume_set_mute),
(gst_volume_class_init), (gst_volume_init),
(volume_process_double), (volume_process_float),
(volume_process_int32), (volume_process_int32_clamp),
(volume_process_int24), (volume_process_int24_clamp),
(volume_process_int16), (volume_process_int16_clamp),
(volume_process_int8), (volume_process_int8_clamp), (volume_setup),
(volume_transform_ip), (volume_set_property),
(volume_get_property):
* gst/volume/gstvolume.h:
Cleanup volume, define and use default values.
Recalculate new volume and mute setup before processing. Fixes #561789.
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
Add controller unit test. Patch by: Jonathan Matthew
Fix bogus test that messed with basetransform's internal state.
2008-11-24 12:03:11 +00:00
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
|
2012-01-31 11:28:30 +00:00
|
|
|
cs = gst_interpolation_control_source_new ();
|
|
|
|
g_object_set (cs, "mode", GST_INTERPOLATION_MODE_CUBIC, NULL);
|
2012-01-20 13:44:19 +00:00
|
|
|
gst_object_add_control_binding (GST_OBJECT_CAST (volume),
|
2012-01-31 11:28:30 +00:00
|
|
|
gst_direct_control_binding_new (GST_OBJECT_CAST (volume), "volume", cs));
|
gst/volume/gstvolume.*: Cleanup volume, define and use default values.
Original commit message from CVS:
* gst/volume/gstvolume.c: (volume_choose_func),
(volume_update_volume), (gst_volume_set_volume),
(gst_volume_get_volume), (gst_volume_set_mute),
(gst_volume_class_init), (gst_volume_init),
(volume_process_double), (volume_process_float),
(volume_process_int32), (volume_process_int32_clamp),
(volume_process_int24), (volume_process_int24_clamp),
(volume_process_int16), (volume_process_int16_clamp),
(volume_process_int8), (volume_process_int8_clamp), (volume_setup),
(volume_transform_ip), (volume_set_property),
(volume_get_property):
* gst/volume/gstvolume.h:
Cleanup volume, define and use default values.
Recalculate new volume and mute setup before processing. Fixes #561789.
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
Add controller unit test. Patch by: Jonathan Matthew
Fix bogus test that messed with basetransform's internal state.
2008-11-24 12:03:11 +00:00
|
|
|
|
2012-04-25 16:43:59 +00:00
|
|
|
/* the value range for volume is 0.0 ... 10.0 */
|
|
|
|
tvcs = (GstTimedValueControlSource *) cs;
|
|
|
|
gst_timed_value_control_source_set (tvcs, 0 * GST_SECOND, 0.1);
|
|
|
|
|
gst/volume/gstvolume.*: Cleanup volume, define and use default values.
Original commit message from CVS:
* gst/volume/gstvolume.c: (volume_choose_func),
(volume_update_volume), (gst_volume_set_volume),
(gst_volume_get_volume), (gst_volume_set_mute),
(gst_volume_class_init), (gst_volume_init),
(volume_process_double), (volume_process_float),
(volume_process_int32), (volume_process_int32_clamp),
(volume_process_int24), (volume_process_int24_clamp),
(volume_process_int16), (volume_process_int16_clamp),
(volume_process_int8), (volume_process_int8_clamp), (volume_setup),
(volume_transform_ip), (volume_set_property),
(volume_get_property):
* gst/volume/gstvolume.h:
Cleanup volume, define and use default values.
Recalculate new volume and mute setup before processing. Fixes #561789.
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
Add controller unit test. Patch by: Jonathan Matthew
Fix bogus test that messed with basetransform's internal state.
2008-11-24 12:03:11 +00:00
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (4);
|
2011-03-28 12:12:24 +00:00
|
|
|
gst_buffer_fill (inbuffer, 0, in, 4);
|
gst/volume/gstvolume.*: Cleanup volume, define and use default values.
Original commit message from CVS:
* gst/volume/gstvolume.c: (volume_choose_func),
(volume_update_volume), (gst_volume_set_volume),
(gst_volume_get_volume), (gst_volume_set_mute),
(gst_volume_class_init), (gst_volume_init),
(volume_process_double), (volume_process_float),
(volume_process_int32), (volume_process_int32_clamp),
(volume_process_int24), (volume_process_int24_clamp),
(volume_process_int16), (volume_process_int16_clamp),
(volume_process_int8), (volume_process_int8_clamp), (volume_setup),
(volume_transform_ip), (volume_set_property),
(volume_get_property):
* gst/volume/gstvolume.h:
Cleanup volume, define and use default values.
Recalculate new volume and mute setup before processing. Fixes #561789.
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
Add controller unit test. Patch by: Jonathan Matthew
Fix bogus test that messed with basetransform's internal state.
2008-11-24 12:03:11 +00:00
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
gst/volume/gstvolume.*: Cleanup volume, define and use default values.
Original commit message from CVS:
* gst/volume/gstvolume.c: (volume_choose_func),
(volume_update_volume), (gst_volume_set_volume),
(gst_volume_get_volume), (gst_volume_set_mute),
(gst_volume_class_init), (gst_volume_init),
(volume_process_double), (volume_process_float),
(volume_process_int32), (volume_process_int32_clamp),
(volume_process_int24), (volume_process_int24_clamp),
(volume_process_int16), (volume_process_int16_clamp),
(volume_process_int8), (volume_process_int8_clamp), (volume_setup),
(volume_transform_ip), (volume_set_property),
(volume_get_property):
* gst/volume/gstvolume.h:
Cleanup volume, define and use default values.
Recalculate new volume and mute setup before processing. Fixes #561789.
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
Add controller unit test. Patch by: Jonathan Matthew
Fix bogus test that messed with basetransform's internal state.
2008-11-24 12:03:11 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
|
2012-02-03 14:01:50 +00:00
|
|
|
gst_segment_init (&seg, GST_FORMAT_TIME);
|
|
|
|
fail_unless (gst_pad_push_event (mysrcpad,
|
|
|
|
gst_event_new_segment (&seg)) == TRUE);
|
|
|
|
|
gst/volume/gstvolume.*: Cleanup volume, define and use default values.
Original commit message from CVS:
* gst/volume/gstvolume.c: (volume_choose_func),
(volume_update_volume), (gst_volume_set_volume),
(gst_volume_get_volume), (gst_volume_set_mute),
(gst_volume_class_init), (gst_volume_init),
(volume_process_double), (volume_process_float),
(volume_process_int32), (volume_process_int32_clamp),
(volume_process_int24), (volume_process_int24_clamp),
(volume_process_int16), (volume_process_int16_clamp),
(volume_process_int8), (volume_process_int8_clamp), (volume_setup),
(volume_transform_ip), (volume_set_property),
(volume_get_property):
* gst/volume/gstvolume.h:
Cleanup volume, define and use default values.
Recalculate new volume and mute setup before processing. Fixes #561789.
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
Add controller unit test. Patch by: Jonathan Matthew
Fix bogus test that messed with basetransform's internal state.
2008-11-24 12:03:11 +00:00
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
/* ... but it ends up being collected on the global buffer list */
|
|
|
|
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
|
|
|
|
fail_unless_equals_int (g_list_length (buffers), 1);
|
|
|
|
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
|
|
|
|
fail_unless (inbuffer == outbuffer);
|
2012-01-20 15:11:54 +00:00
|
|
|
gst_buffer_map (outbuffer, &map, GST_MAP_READ);
|
2012-04-25 16:42:04 +00:00
|
|
|
out = (gint16 *) map.data;
|
|
|
|
GST_INFO ("expected %+5d %+5d real %+5d %+5d", in[0], in[1], out[0], out[1]);
|
2012-01-20 15:11:54 +00:00
|
|
|
fail_unless (memcmp (map.data, in, 4) == 0);
|
|
|
|
gst_buffer_unmap (outbuffer, &map);
|
gst/volume/gstvolume.*: Cleanup volume, define and use default values.
Original commit message from CVS:
* gst/volume/gstvolume.c: (volume_choose_func),
(volume_update_volume), (gst_volume_set_volume),
(gst_volume_get_volume), (gst_volume_set_mute),
(gst_volume_class_init), (gst_volume_init),
(volume_process_double), (volume_process_float),
(volume_process_int32), (volume_process_int32_clamp),
(volume_process_int24), (volume_process_int24_clamp),
(volume_process_int16), (volume_process_int16_clamp),
(volume_process_int8), (volume_process_int8_clamp), (volume_setup),
(volume_transform_ip), (volume_set_property),
(volume_get_property):
* gst/volume/gstvolume.h:
Cleanup volume, define and use default values.
Recalculate new volume and mute setup before processing. Fixes #561789.
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
Add controller unit test. Patch by: Jonathan Matthew
Fix bogus test that messed with basetransform's internal state.
2008-11-24 12:03:11 +00:00
|
|
|
|
2012-01-31 11:28:30 +00:00
|
|
|
gst_object_unref (cs);
|
gst/volume/gstvolume.*: Cleanup volume, define and use default values.
Original commit message from CVS:
* gst/volume/gstvolume.c: (volume_choose_func),
(volume_update_volume), (gst_volume_set_volume),
(gst_volume_get_volume), (gst_volume_set_mute),
(gst_volume_class_init), (gst_volume_init),
(volume_process_double), (volume_process_float),
(volume_process_int32), (volume_process_int32_clamp),
(volume_process_int24), (volume_process_int24_clamp),
(volume_process_int16), (volume_process_int16_clamp),
(volume_process_int8), (volume_process_int8_clamp), (volume_setup),
(volume_transform_ip), (volume_set_property),
(volume_get_property):
* gst/volume/gstvolume.h:
Cleanup volume, define and use default values.
Recalculate new volume and mute setup before processing. Fixes #561789.
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
Add controller unit test. Patch by: Jonathan Matthew
Fix bogus test that messed with basetransform's internal state.
2008-11-24 12:03:11 +00:00
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2013-01-09 22:15:06 +00:00
|
|
|
GST_START_TEST (test_controller_defaults_at_ts0)
|
|
|
|
{
|
|
|
|
GstControlSource *cs;
|
|
|
|
GstTimedValueControlSource *tvcs;
|
|
|
|
GstElement *volume;
|
|
|
|
GstBuffer *inbuffer;
|
|
|
|
GstCaps *caps;
|
|
|
|
GstSegment seg;
|
|
|
|
|
|
|
|
volume = setup_volume ();
|
|
|
|
|
|
|
|
cs = gst_interpolation_control_source_new ();
|
|
|
|
g_object_set (cs, "mode", GST_INTERPOLATION_MODE_LINEAR, NULL);
|
|
|
|
gst_object_add_control_binding (GST_OBJECT_CAST (volume),
|
|
|
|
gst_direct_control_binding_new (GST_OBJECT_CAST (volume), "volume", cs));
|
|
|
|
|
|
|
|
/* make a control curve that does not start at ts=0, the element will use
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
* the current property value (default) until the control curve starts
|
2013-01-09 22:15:06 +00:00
|
|
|
*/
|
|
|
|
tvcs = (GstTimedValueControlSource *) cs;
|
|
|
|
gst_timed_value_control_source_set (tvcs, GST_SECOND / 100, 0.1);
|
|
|
|
gst_timed_value_control_source_set (tvcs, GST_SECOND, 1.0);
|
|
|
|
|
|
|
|
fail_unless (gst_element_set_state (volume,
|
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
|
|
|
|
"could not set to playing");
|
|
|
|
|
|
|
|
/* controller curve starts at sample: 441 */
|
|
|
|
inbuffer = gst_buffer_new_and_alloc (1000 * sizeof (gint16));
|
|
|
|
gst_buffer_memset (inbuffer, 0, 0, 1000 * sizeof (gint16));
|
|
|
|
caps = gst_caps_from_string (VOLUME_CAPS_STRING_S16);
|
2013-05-10 10:29:15 +00:00
|
|
|
gst_check_setup_events (mysrcpad, volume, caps, GST_FORMAT_TIME);
|
2013-01-09 22:15:06 +00:00
|
|
|
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
|
|
|
|
gst_caps_unref (caps);
|
|
|
|
|
|
|
|
gst_segment_init (&seg, GST_FORMAT_TIME);
|
|
|
|
fail_unless (gst_pad_push_event (mysrcpad,
|
|
|
|
gst_event_new_segment (&seg)) == TRUE);
|
|
|
|
|
|
|
|
/* pushing gives away my reference ... */
|
|
|
|
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
|
|
|
|
|
|
|
|
gst_object_unref (cs);
|
|
|
|
cleanup_volume (volume);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2007-05-04 12:41:21 +00:00
|
|
|
static Suite *
|
2005-08-20 18:07:10 +00:00
|
|
|
volume_suite (void)
|
|
|
|
{
|
|
|
|
Suite *s = suite_create ("volume");
|
|
|
|
TCase *tc_chain = tcase_create ("general");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
2009-09-11 13:04:42 +00:00
|
|
|
tcase_add_test (tc_chain, test_get_set);
|
2007-09-05 21:20:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_unity_s8);
|
|
|
|
tcase_add_test (tc_chain, test_half_s8);
|
|
|
|
tcase_add_test (tc_chain, test_double_s8);
|
2011-05-31 09:05:03 +00:00
|
|
|
tcase_add_test (tc_chain, test_ten_s8);
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
tcase_add_test (tc_chain, test_fifteen_s8);
|
|
|
|
tcase_add_test (tc_chain, test_sixteen_s8);
|
|
|
|
tcase_add_test (tc_chain, test_max_s8);
|
2007-09-05 21:20:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_mute_s8);
|
|
|
|
tcase_add_test (tc_chain, test_unity_s16);
|
|
|
|
tcase_add_test (tc_chain, test_half_s16);
|
|
|
|
tcase_add_test (tc_chain, test_double_s16);
|
2011-05-31 09:05:03 +00:00
|
|
|
tcase_add_test (tc_chain, test_ten_s16);
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
tcase_add_test (tc_chain, test_fifteen_s16);
|
|
|
|
tcase_add_test (tc_chain, test_sixteen_s16);
|
|
|
|
tcase_add_test (tc_chain, test_max_s16);
|
2007-09-05 21:20:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_mute_s16);
|
|
|
|
tcase_add_test (tc_chain, test_unity_s24);
|
|
|
|
tcase_add_test (tc_chain, test_half_s24);
|
|
|
|
tcase_add_test (tc_chain, test_double_s24);
|
2011-05-31 09:05:03 +00:00
|
|
|
tcase_add_test (tc_chain, test_ten_s24);
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
tcase_add_test (tc_chain, test_fifteen_s24);
|
|
|
|
tcase_add_test (tc_chain, test_sixteen_s24);
|
|
|
|
tcase_add_test (tc_chain, test_4095_s24);
|
|
|
|
tcase_add_test (tc_chain, test_4096_s24);
|
|
|
|
tcase_add_test (tc_chain, test_max_s24);
|
2007-09-05 21:20:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_mute_s24);
|
|
|
|
tcase_add_test (tc_chain, test_unity_s32);
|
|
|
|
tcase_add_test (tc_chain, test_half_s32);
|
|
|
|
tcase_add_test (tc_chain, test_double_s32);
|
2011-05-31 09:05:03 +00:00
|
|
|
tcase_add_test (tc_chain, test_ten_s32);
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
tcase_add_test (tc_chain, test_fifteen_s32);
|
|
|
|
tcase_add_test (tc_chain, test_sixteen_s32);
|
|
|
|
tcase_add_test (tc_chain, test_max_s32);
|
2007-09-05 21:20:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_mute_s32);
|
|
|
|
tcase_add_test (tc_chain, test_unity_f32);
|
|
|
|
tcase_add_test (tc_chain, test_half_f32);
|
|
|
|
tcase_add_test (tc_chain, test_double_f32);
|
2011-05-31 09:05:03 +00:00
|
|
|
tcase_add_test (tc_chain, test_ten_f32);
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
tcase_add_test (tc_chain, test_fifteen_f32);
|
|
|
|
tcase_add_test (tc_chain, test_sixteen_f32);
|
|
|
|
tcase_add_test (tc_chain, test_max_f32);
|
2007-09-05 21:20:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_mute_f32);
|
|
|
|
tcase_add_test (tc_chain, test_unity_f64);
|
|
|
|
tcase_add_test (tc_chain, test_half_f64);
|
|
|
|
tcase_add_test (tc_chain, test_double_f64);
|
2011-05-31 09:05:03 +00:00
|
|
|
tcase_add_test (tc_chain, test_ten_f64);
|
volume: support arbitrarily-large positive gains
The current limit is `x10`, which allows just `+20 dB` of gain.
While it may seem sufficient, this came up as a problem
in a real-world, non-specially-engineered situation,
in strawberry's EBU R 128 loudness normalization.
(https://github.com/strawberrymusicplayer/strawberry/pull/1216)
There is an audio track (that was not intentionally engineered that way),
that has integrated loudness of `-38 LUFS`,
and if we want to normalize it's loudness to e.g. `-16 LUFS`,
which is a very reasonable thing to do,
we need to apply gain of `+22 dB`,
which is larger than `+20 dB`, and we fail...
I think it should allow at least `+96 dB` of gain,
and therefore should be at `10^(96/20) ~= 63096`.
But, i don't see why we need to put any specific restriction
on that parameter in the first place, other than the fact
that the fixed-point multiplication scheme does not support volume
larger than 15x-ish.
So let's just implement a floating-point fall-back path
that does not involve fixed-point multiplication
and lift the restriction altogether?
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5063>
2023-07-19 00:11:52 +00:00
|
|
|
tcase_add_test (tc_chain, test_fifteen_f64);
|
|
|
|
tcase_add_test (tc_chain, test_sixteen_f64);
|
|
|
|
tcase_add_test (tc_chain, test_max_f64);
|
2007-09-05 21:20:12 +00:00
|
|
|
tcase_add_test (tc_chain, test_mute_f64);
|
2005-08-20 20:40:25 +00:00
|
|
|
tcase_add_test (tc_chain, test_wrong_caps);
|
gst/volume/gstvolume.*: rewrite the passthrough check, split _int16 and _int16_clamp, fix another property desc., rem...
Original commit message from CVS:
* gst/volume/gstvolume.c: (volume_choose_func),
(volume_update_real_volume), (gst_volume_class_init),
(gst_volume_init), (volume_process_float), (volume_process_int16),
(volume_process_int16_clamp), (volume_set_caps),
(volume_transform_ip), (plugin_init):
* gst/volume/gstvolume.h:
rewrite the passthrough check, split _int16 and _int16_clamp, fix
another property desc., remove unused param from process function
* tests/check/elements/volume.c: (volume_suite):
reactivate the passthrough test
2006-06-01 20:39:30 +00:00
|
|
|
tcase_add_test (tc_chain, test_passthrough);
|
2007-05-04 12:41:21 +00:00
|
|
|
tcase_add_test (tc_chain, test_controller_usability);
|
gst/volume/gstvolume.*: Cleanup volume, define and use default values.
Original commit message from CVS:
* gst/volume/gstvolume.c: (volume_choose_func),
(volume_update_volume), (gst_volume_set_volume),
(gst_volume_get_volume), (gst_volume_set_mute),
(gst_volume_class_init), (gst_volume_init),
(volume_process_double), (volume_process_float),
(volume_process_int32), (volume_process_int32_clamp),
(volume_process_int24), (volume_process_int24_clamp),
(volume_process_int16), (volume_process_int16_clamp),
(volume_process_int8), (volume_process_int8_clamp), (volume_setup),
(volume_transform_ip), (volume_set_property),
(volume_get_property):
* gst/volume/gstvolume.h:
Cleanup volume, define and use default values.
Recalculate new volume and mute setup before processing. Fixes #561789.
* tests/check/elements/volume.c: (GST_START_TEST), (volume_suite):
Add controller unit test. Patch by: Jonathan Matthew
Fix bogus test that messed with basetransform's internal state.
2008-11-24 12:03:11 +00:00
|
|
|
tcase_add_test (tc_chain, test_controller_processing);
|
2013-01-09 22:15:06 +00:00
|
|
|
tcase_add_test (tc_chain, test_controller_defaults_at_ts0);
|
2005-08-20 18:07:10 +00:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2007-05-04 12:41:21 +00:00
|
|
|
GST_CHECK_MAIN (volume)
|