gstreamer/subprojects/gst-plugins-good/ext/wavpack/gstwavpackdec.c

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

483 lines
14 KiB
C
Raw Normal View History

/* GStreamer Wavpack plugin
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
* Copyright (c) 2005 Arwed v. Merkatz <v.merkatz@gmx.net>
* Copyright (c) 2006 Edward Hervey <bilboed@gmail.com>
* Copyright (c) 2006 Sebastian Dröge <slomo@circular-chaos.org>
*
* gstwavpackdec.c: raw Wavpack bitstream decoder
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/**
* SECTION:element-wavpackdec
* @title: wavpackdec
*
* WavpackDec decodes framed (for example by the WavpackParse element)
* Wavpack streams and decodes them to raw audio.
* [Wavpack](http://www.wavpack.com/) is an open-source audio codec that
* features both lossless and lossy encoding.
*
* ## Example launch line
* |[
* gst-launch-1.0 filesrc location=test.wv ! wavpackparse ! wavpackdec ! audioconvert ! audioresample ! autoaudiosink
* ]| This pipeline decodes the Wavpack file test.wv into raw audio buffers and
* tries to play it back using an automatically found audio sink.
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gst/gst.h>
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
#include <gst/audio/audio.h>
#include <math.h>
#include <string.h>
#include <wavpack/wavpack.h>
#include "gstwavpackelements.h"
#include "gstwavpackdec.h"
#include "gstwavpackcommon.h"
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
#include "gstwavpackstreamreader.h"
ext/wavpack/gstwavpackdec.c: Add debug category, use boilerplate macros, fix handling of widths of 32 bits. Original commit message from CVS: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_setcaps), (gst_wavpack_dec_base_init), (gst_wavpack_dec_dispose), (gst_wavpack_dec_class_init), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_init), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_chain), (gst_wavpack_dec_plugin_init): Add debug category, use boilerplate macros, fix handling of widths of 32 bits. * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_dispose), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_last_entry), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_index_append_entry), (gst_wavpack_parse_reset), (gst_wavpack_parse_src_query), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_send_newsegment), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_src_event), (gst_wavpack_parse_init), (gst_wavpack_parse_get_upstream_length), (gst_wavpack_parse_pull_buffer), (gst_wavpack_parse_create_src_pad), (gst_wavpack_parse_loop), (gst_wavpack_parse_change_state), (gst_wavepack_parse_sink_activate), (gst_wavepack_parse_sink_activate_pull), (gst_wavpack_parse_plugin_init): * ext/wavpack/gstwavpackparse.h: Rewrite a bit, mostly to fix flow logic and to make seeking work. Fix buffer/event refcounting. Add some debug statements. Add width of 32 to source pad template caps. Use boilerplate macros.
2006-01-29 20:07:49 +00:00
GST_DEBUG_CATEGORY_STATIC (gst_wavpack_dec_debug);
#define GST_CAT_DEFAULT gst_wavpack_dec_debug
static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-wavpack, "
2012-03-05 12:36:39 +00:00
"depth = (int) [ 1, 32 ], "
ext/wavpack/: Add support for encoding, parsing and decoding multichannel files with up to 8 channels. This also impr... Original commit message from CVS: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_get_default_channel_mask), (gst_wavpack_set_channel_layout), (gst_wavpack_get_default_channel_positions), (gst_wavpack_get_channel_mask_from_positions), (gst_wavpack_set_channel_mapping): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), (gst_wavpack_dec_sink_set_caps), (gst_wavpack_dec_chain): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_reset), (gst_wavpack_enc_init), (gst_wavpack_enc_sink_set_caps), (gst_wavpack_enc_set_wp_config), (gst_wavpack_enc_push_block), (gst_wavpack_enc_fix_channel_order), (gst_wavpack_enc_chain), (gst_wavpack_enc_rewrite_first_block), (gst_wavpack_enc_sink_event): * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_index_append_entry), (gst_wavpack_parse_reset), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_sink_event), (gst_wavpack_parse_create_src_pad), (gst_wavpack_parse_push_buffer), (gst_wavpack_parse_loop): * ext/wavpack/gstwavpackparse.h: Add support for encoding, parsing and decoding multichannel files with up to 8 channels. This also improves the robustness of parsing quite a bit. * ext/wavpack/gstwavpackstreamreader.c: (gst_wavpack_stream_reader_read_bytes), (gst_wavpack_stream_reader_get_pos), (gst_wavpack_stream_reader_set_pos_abs), (gst_wavpack_stream_reader_set_pos_rel), (gst_wavpack_stream_reader_push_back_byte), (gst_wavpack_stream_reader_get_length), (gst_wavpack_stream_reader_can_seek), (gst_wavpack_stream_reader_write_bytes): Improve debugging.
2007-11-20 13:08:45 +00:00
"channels = (int) [ 1, 8 ], "
"rate = (int) [ 6000, 192000 ], " "framed = (boolean) true")
);
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
2012-03-05 12:36:39 +00:00
GST_STATIC_CAPS ("audio/x-raw, "
"format = (string) S8, "
"layout = (string) interleaved, "
ext/wavpack/: Add support for encoding, parsing and decoding multichannel files with up to 8 channels. This also impr... Original commit message from CVS: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_get_default_channel_mask), (gst_wavpack_set_channel_layout), (gst_wavpack_get_default_channel_positions), (gst_wavpack_get_channel_mask_from_positions), (gst_wavpack_set_channel_mapping): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), (gst_wavpack_dec_sink_set_caps), (gst_wavpack_dec_chain): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_reset), (gst_wavpack_enc_init), (gst_wavpack_enc_sink_set_caps), (gst_wavpack_enc_set_wp_config), (gst_wavpack_enc_push_block), (gst_wavpack_enc_fix_channel_order), (gst_wavpack_enc_chain), (gst_wavpack_enc_rewrite_first_block), (gst_wavpack_enc_sink_event): * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_index_append_entry), (gst_wavpack_parse_reset), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_sink_event), (gst_wavpack_parse_create_src_pad), (gst_wavpack_parse_push_buffer), (gst_wavpack_parse_loop): * ext/wavpack/gstwavpackparse.h: Add support for encoding, parsing and decoding multichannel files with up to 8 channels. This also improves the robustness of parsing quite a bit. * ext/wavpack/gstwavpackstreamreader.c: (gst_wavpack_stream_reader_read_bytes), (gst_wavpack_stream_reader_get_pos), (gst_wavpack_stream_reader_set_pos_abs), (gst_wavpack_stream_reader_set_pos_rel), (gst_wavpack_stream_reader_push_back_byte), (gst_wavpack_stream_reader_get_length), (gst_wavpack_stream_reader_can_seek), (gst_wavpack_stream_reader_write_bytes): Improve debugging.
2007-11-20 13:08:45 +00:00
"channels = (int) [ 1, 8 ], "
2012-03-05 12:36:39 +00:00
"rate = (int) [ 6000, 192000 ]; "
"audio/x-raw, "
"format = (string) " GST_AUDIO_NE (S16) ", "
"layout = (string) interleaved, "
ext/wavpack/: Add support for encoding, parsing and decoding multichannel files with up to 8 channels. This also impr... Original commit message from CVS: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_get_default_channel_mask), (gst_wavpack_set_channel_layout), (gst_wavpack_get_default_channel_positions), (gst_wavpack_get_channel_mask_from_positions), (gst_wavpack_set_channel_mapping): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), (gst_wavpack_dec_sink_set_caps), (gst_wavpack_dec_chain): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_reset), (gst_wavpack_enc_init), (gst_wavpack_enc_sink_set_caps), (gst_wavpack_enc_set_wp_config), (gst_wavpack_enc_push_block), (gst_wavpack_enc_fix_channel_order), (gst_wavpack_enc_chain), (gst_wavpack_enc_rewrite_first_block), (gst_wavpack_enc_sink_event): * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_index_append_entry), (gst_wavpack_parse_reset), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_sink_event), (gst_wavpack_parse_create_src_pad), (gst_wavpack_parse_push_buffer), (gst_wavpack_parse_loop): * ext/wavpack/gstwavpackparse.h: Add support for encoding, parsing and decoding multichannel files with up to 8 channels. This also improves the robustness of parsing quite a bit. * ext/wavpack/gstwavpackstreamreader.c: (gst_wavpack_stream_reader_read_bytes), (gst_wavpack_stream_reader_get_pos), (gst_wavpack_stream_reader_set_pos_abs), (gst_wavpack_stream_reader_set_pos_rel), (gst_wavpack_stream_reader_push_back_byte), (gst_wavpack_stream_reader_get_length), (gst_wavpack_stream_reader_can_seek), (gst_wavpack_stream_reader_write_bytes): Improve debugging.
2007-11-20 13:08:45 +00:00
"channels = (int) [ 1, 8 ], "
2012-03-05 12:36:39 +00:00
"rate = (int) [ 6000, 192000 ]; "
"audio/x-raw, "
"format = (string) " GST_AUDIO_NE (S32) ", "
"layout = (string) interleaved, "
"channels = (int) [ 1, 8 ], " "rate = (int) [ 6000, 192000 ]; "
"audio/x-raw, "
"format = (string) " GST_AUDIO_NE (F32) ", "
"layout = (string) interleaved, "
2012-03-05 12:36:39 +00:00
"channels = (int) [ 1, 8 ], " "rate = (int) [ 6000, 192000 ]")
);
2012-02-27 22:46:03 +00:00
static gboolean gst_wavpack_dec_start (GstAudioDecoder * dec);
static gboolean gst_wavpack_dec_stop (GstAudioDecoder * dec);
static gboolean gst_wavpack_dec_set_format (GstAudioDecoder * dec,
GstCaps * caps);
static GstFlowReturn gst_wavpack_dec_handle_frame (GstAudioDecoder * dec,
GstBuffer * buffer);
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
static void gst_wavpack_dec_finalize (GObject * object);
ext/wavpack/: Don't play audioconvert. As wavpack wants/outputs all samples with width==32 and depth=[1,32] accept th... Original commit message from CVS: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), (gst_wavpack_dec_init), (gst_wavpack_dec_sink_set_caps), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_post_tags), (gst_wavpack_dec_chain): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_reset), (gst_wavpack_enc_sink_set_caps), (gst_wavpack_enc_set_wp_config), (gst_wavpack_enc_chain): * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.c: Don't play audioconvert. As wavpack wants/outputs all samples with width==32 and depth=[1,32] accept this and let audioconvert convert to accepted formats instead of doing it in the element for n*8 depths. This also adds support for non-n*8 depths and prevents some useless memory allocations. Fixes #421598 Also add a workaround for bug #421542 in wavpackenc for now... * tests/check/elements/wavpackdec.c: (GST_START_TEST): * tests/check/elements/wavpackenc.c: (GST_START_TEST): * tests/check/elements/wavpackparse.c: (GST_START_TEST): Consider the change above in the unit tests and test if the correct caps are accepted and set. Also check for GST_BUFFER_OFFSET_END in the wavpackparse unit test. * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_init), (gst_wavpack_dec_sink_set_caps): Set caps on the src pad as soon as possible. * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.h: Fix indention. gst-indent is now called by cicl.
2007-03-30 04:50:11 +00:00
static void gst_wavpack_dec_post_tags (GstWavpackDec * dec);
2012-03-05 12:36:39 +00:00
#define gst_wavpack_dec_parent_class parent_class
G_DEFINE_TYPE (GstWavpackDec, gst_wavpack_dec, GST_TYPE_AUDIO_DECODER);
#define _do_init \
GST_DEBUG_CATEGORY_INIT (gst_wavpack_dec_debug, "wavpackdec", 0, \
"Wavpack decoder"); \
wavpack_element_init (plugin);
GST_ELEMENT_REGISTER_DEFINE_WITH_CODE (wavpackdec, "wavpackdec",
GST_RANK_PRIMARY, GST_TYPE_WAVPACK_DEC, _do_init);
static void
2012-03-05 12:36:39 +00:00
gst_wavpack_dec_class_init (GstWavpackDecClass * klass)
{
2012-03-05 12:36:39 +00:00
GObjectClass *gobject_class = (GObjectClass *) klass;
GstElementClass *element_class = (GstElementClass *) (klass);
GstAudioDecoderClass *base_class = (GstAudioDecoderClass *) (klass);
gst_element_class_add_static_pad_template (element_class, &src_factory);
gst_element_class_add_static_pad_template (element_class, &sink_factory);
gst_element_class_set_static_metadata (element_class, "Wavpack audio decoder",
"Codec/Decoder/Audio",
"Decodes Wavpack audio data",
"Arwed v. Merkatz <v.merkatz@gmx.net>, "
"Sebastian Dröge <slomo@circular-chaos.org>");
ext/wavpack/gstwavpackdec.c: Add debug category, use boilerplate macros, fix handling of widths of 32 bits. Original commit message from CVS: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_setcaps), (gst_wavpack_dec_base_init), (gst_wavpack_dec_dispose), (gst_wavpack_dec_class_init), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_init), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_chain), (gst_wavpack_dec_plugin_init): Add debug category, use boilerplate macros, fix handling of widths of 32 bits. * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_dispose), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_last_entry), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_index_append_entry), (gst_wavpack_parse_reset), (gst_wavpack_parse_src_query), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_send_newsegment), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_src_event), (gst_wavpack_parse_init), (gst_wavpack_parse_get_upstream_length), (gst_wavpack_parse_pull_buffer), (gst_wavpack_parse_create_src_pad), (gst_wavpack_parse_loop), (gst_wavpack_parse_change_state), (gst_wavepack_parse_sink_activate), (gst_wavepack_parse_sink_activate_pull), (gst_wavpack_parse_plugin_init): * ext/wavpack/gstwavpackparse.h: Rewrite a bit, mostly to fix flow logic and to make seeking work. Fix buffer/event refcounting. Add some debug statements. Add width of 32 to source pad template caps. Use boilerplate macros.
2006-01-29 20:07:49 +00:00
gobject_class->finalize = gst_wavpack_dec_finalize;
2012-02-27 22:46:03 +00:00
base_class->start = GST_DEBUG_FUNCPTR (gst_wavpack_dec_start);
base_class->stop = GST_DEBUG_FUNCPTR (gst_wavpack_dec_stop);
base_class->set_format = GST_DEBUG_FUNCPTR (gst_wavpack_dec_set_format);
base_class->handle_frame = GST_DEBUG_FUNCPTR (gst_wavpack_dec_handle_frame);
ext/wavpack/gstwavpackdec.c: Add debug category, use boilerplate macros, fix handling of widths of 32 bits. Original commit message from CVS: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_setcaps), (gst_wavpack_dec_base_init), (gst_wavpack_dec_dispose), (gst_wavpack_dec_class_init), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_init), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_chain), (gst_wavpack_dec_plugin_init): Add debug category, use boilerplate macros, fix handling of widths of 32 bits. * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_dispose), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_last_entry), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_index_append_entry), (gst_wavpack_parse_reset), (gst_wavpack_parse_src_query), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_send_newsegment), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_src_event), (gst_wavpack_parse_init), (gst_wavpack_parse_get_upstream_length), (gst_wavpack_parse_pull_buffer), (gst_wavpack_parse_create_src_pad), (gst_wavpack_parse_loop), (gst_wavpack_parse_change_state), (gst_wavepack_parse_sink_activate), (gst_wavepack_parse_sink_activate_pull), (gst_wavpack_parse_plugin_init): * ext/wavpack/gstwavpackparse.h: Rewrite a bit, mostly to fix flow logic and to make seeking work. Fix buffer/event refcounting. Add some debug statements. Add width of 32 to source pad template caps. Use boilerplate macros.
2006-01-29 20:07:49 +00:00
}
static void
gst_wavpack_dec_reset (GstWavpackDec * dec)
{
dec->wv_id.buffer = NULL;
dec->wv_id.position = dec->wv_id.length = 0;
dec->channels = 0;
ext/wavpack/: Add support for encoding, parsing and decoding multichannel files with up to 8 channels. This also impr... Original commit message from CVS: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_get_default_channel_mask), (gst_wavpack_set_channel_layout), (gst_wavpack_get_default_channel_positions), (gst_wavpack_get_channel_mask_from_positions), (gst_wavpack_set_channel_mapping): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), (gst_wavpack_dec_sink_set_caps), (gst_wavpack_dec_chain): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_reset), (gst_wavpack_enc_init), (gst_wavpack_enc_sink_set_caps), (gst_wavpack_enc_set_wp_config), (gst_wavpack_enc_push_block), (gst_wavpack_enc_fix_channel_order), (gst_wavpack_enc_chain), (gst_wavpack_enc_rewrite_first_block), (gst_wavpack_enc_sink_event): * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_index_append_entry), (gst_wavpack_parse_reset), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_sink_event), (gst_wavpack_parse_create_src_pad), (gst_wavpack_parse_push_buffer), (gst_wavpack_parse_loop): * ext/wavpack/gstwavpackparse.h: Add support for encoding, parsing and decoding multichannel files with up to 8 channels. This also improves the robustness of parsing quite a bit. * ext/wavpack/gstwavpackstreamreader.c: (gst_wavpack_stream_reader_read_bytes), (gst_wavpack_stream_reader_get_pos), (gst_wavpack_stream_reader_set_pos_abs), (gst_wavpack_stream_reader_set_pos_rel), (gst_wavpack_stream_reader_push_back_byte), (gst_wavpack_stream_reader_get_length), (gst_wavpack_stream_reader_can_seek), (gst_wavpack_stream_reader_write_bytes): Improve debugging.
2007-11-20 13:08:45 +00:00
dec->channel_mask = 0;
dec->sample_rate = 0;
dec->depth = 0;
dec->mode_float = FALSE;
}
static void
2012-03-05 12:36:39 +00:00
gst_wavpack_dec_init (GstWavpackDec * dec)
{
dec->context = NULL;
dec->stream_reader = gst_wavpack_stream_reader_new ();
gst_audio_decoder_set_needs_format (GST_AUDIO_DECODER (dec), TRUE);
gst_audio_decoder_set_use_default_pad_acceptcaps (GST_AUDIO_DECODER_CAST
(dec), TRUE);
GST_PAD_SET_ACCEPT_TEMPLATE (GST_AUDIO_DECODER_SINK_PAD (dec));
gst_wavpack_dec_reset (dec);
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
}
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
static void
gst_wavpack_dec_finalize (GObject * object)
{
GstWavpackDec *dec = GST_WAVPACK_DEC (object);
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
g_free (dec->stream_reader);
dec->stream_reader = NULL;
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
G_OBJECT_CLASS (parent_class)->finalize (object);
}
ext/wavpack/: Don't play audioconvert. As wavpack wants/outputs all samples with width==32 and depth=[1,32] accept th... Original commit message from CVS: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), (gst_wavpack_dec_init), (gst_wavpack_dec_sink_set_caps), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_post_tags), (gst_wavpack_dec_chain): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_reset), (gst_wavpack_enc_sink_set_caps), (gst_wavpack_enc_set_wp_config), (gst_wavpack_enc_chain): * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.c: Don't play audioconvert. As wavpack wants/outputs all samples with width==32 and depth=[1,32] accept this and let audioconvert convert to accepted formats instead of doing it in the element for n*8 depths. This also adds support for non-n*8 depths and prevents some useless memory allocations. Fixes #421598 Also add a workaround for bug #421542 in wavpackenc for now... * tests/check/elements/wavpackdec.c: (GST_START_TEST): * tests/check/elements/wavpackenc.c: (GST_START_TEST): * tests/check/elements/wavpackparse.c: (GST_START_TEST): Consider the change above in the unit tests and test if the correct caps are accepted and set. Also check for GST_BUFFER_OFFSET_END in the wavpackparse unit test. * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_init), (gst_wavpack_dec_sink_set_caps): Set caps on the src pad as soon as possible. * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.h: Fix indention. gst-indent is now called by cicl.
2007-03-30 04:50:11 +00:00
static gboolean
2012-02-27 22:46:03 +00:00
gst_wavpack_dec_start (GstAudioDecoder * dec)
{
2012-02-27 22:46:03 +00:00
GST_DEBUG_OBJECT (dec, "start");
/* never mind a few errors */
gst_audio_decoder_set_max_errors (dec, 16);
/* don't bother us with flushing */
gst_audio_decoder_set_drainable (dec, FALSE);
/* aim for some perfect timestamping */
gst_audio_decoder_set_tolerance (dec, 10 * GST_MSECOND);
2012-02-27 22:46:03 +00:00
return TRUE;
}
static gboolean
gst_wavpack_dec_stop (GstAudioDecoder * dec)
{
2012-02-27 22:46:03 +00:00
GstWavpackDec *wpdec = GST_WAVPACK_DEC (dec);
GST_DEBUG_OBJECT (dec, "stop");
if (wpdec->context) {
WavpackCloseFile (wpdec->context);
wpdec->context = NULL;
}
gst_wavpack_dec_reset (wpdec);
return TRUE;
}
static void
gst_wavpack_dec_negotiate (GstWavpackDec * dec)
{
2012-03-05 12:36:39 +00:00
GstAudioInfo info;
GstAudioFormat fmt;
GstAudioChannelPosition pos[64] = { GST_AUDIO_CHANNEL_POSITION_INVALID, };
2012-02-27 22:46:03 +00:00
/* arrange for 1, 2 or 4-byte width == depth output */
2012-03-05 12:36:39 +00:00
dec->width = dec->depth;
switch (dec->depth) {
case 8:
fmt = GST_AUDIO_FORMAT_S8;
break;
case 16:
fmt = _GST_AUDIO_FORMAT_NE (S16);
break;
case 24:
case 32:
fmt =
dec->mode_float ? _GST_AUDIO_FORMAT_NE (F32) :
_GST_AUDIO_FORMAT_NE (S32);
2012-03-05 12:36:39 +00:00
dec->width = 32;
break;
default:
fmt = GST_AUDIO_FORMAT_UNKNOWN;
2012-03-05 12:36:39 +00:00
g_assert_not_reached ();
break;
}
g_assert (dec->channel_mask != 0);
if (!gst_wavpack_get_channel_positions (dec->channels,
dec->channel_mask, pos))
GST_WARNING_OBJECT (dec, "Failed to set channel layout");
gst_audio_info_init (&info);
gst_audio_info_set_format (&info, fmt, dec->sample_rate, dec->channels, pos);
gst_audio_channel_positions_to_valid_order (info.position, info.channels);
gst_audio_get_channel_reorder_map (info.channels,
info.position, pos, dec->channel_reorder_map);
2012-02-27 22:46:03 +00:00
/* should always succeed */
2012-03-05 12:36:39 +00:00
gst_audio_decoder_set_output_format (GST_AUDIO_DECODER (dec), &info);
2012-02-27 22:46:03 +00:00
}
static gboolean
gst_wavpack_dec_set_format (GstAudioDecoder * bdec, GstCaps * caps)
{
2012-03-05 12:36:39 +00:00
/* pretty much nothing to do here,
* we'll parse it all from the stream and setup then */
ext/wavpack/: Don't play audioconvert. As wavpack wants/outputs all samples with width==32 and depth=[1,32] accept th... Original commit message from CVS: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), (gst_wavpack_dec_init), (gst_wavpack_dec_sink_set_caps), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_post_tags), (gst_wavpack_dec_chain): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_reset), (gst_wavpack_enc_sink_set_caps), (gst_wavpack_enc_set_wp_config), (gst_wavpack_enc_chain): * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.c: Don't play audioconvert. As wavpack wants/outputs all samples with width==32 and depth=[1,32] accept this and let audioconvert convert to accepted formats instead of doing it in the element for n*8 depths. This also adds support for non-n*8 depths and prevents some useless memory allocations. Fixes #421598 Also add a workaround for bug #421542 in wavpackenc for now... * tests/check/elements/wavpackdec.c: (GST_START_TEST): * tests/check/elements/wavpackenc.c: (GST_START_TEST): * tests/check/elements/wavpackparse.c: (GST_START_TEST): Consider the change above in the unit tests and test if the correct caps are accepted and set. Also check for GST_BUFFER_OFFSET_END in the wavpackparse unit test. * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_init), (gst_wavpack_dec_sink_set_caps): Set caps on the src pad as soon as possible. * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.h: Fix indention. gst-indent is now called by cicl.
2007-03-30 04:50:11 +00:00
return TRUE;
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
}
static void
ext/wavpack/: Don't play audioconvert. As wavpack wants/outputs all samples with width==32 and depth=[1,32] accept th... Original commit message from CVS: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), (gst_wavpack_dec_init), (gst_wavpack_dec_sink_set_caps), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_post_tags), (gst_wavpack_dec_chain): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_reset), (gst_wavpack_enc_sink_set_caps), (gst_wavpack_enc_set_wp_config), (gst_wavpack_enc_chain): * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.c: Don't play audioconvert. As wavpack wants/outputs all samples with width==32 and depth=[1,32] accept this and let audioconvert convert to accepted formats instead of doing it in the element for n*8 depths. This also adds support for non-n*8 depths and prevents some useless memory allocations. Fixes #421598 Also add a workaround for bug #421542 in wavpackenc for now... * tests/check/elements/wavpackdec.c: (GST_START_TEST): * tests/check/elements/wavpackenc.c: (GST_START_TEST): * tests/check/elements/wavpackparse.c: (GST_START_TEST): Consider the change above in the unit tests and test if the correct caps are accepted and set. Also check for GST_BUFFER_OFFSET_END in the wavpackparse unit test. * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_init), (gst_wavpack_dec_sink_set_caps): Set caps on the src pad as soon as possible. * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.h: Fix indention. gst-indent is now called by cicl.
2007-03-30 04:50:11 +00:00
gst_wavpack_dec_post_tags (GstWavpackDec * dec)
{
GstTagList *list;
GstFormat format_time = GST_FORMAT_TIME, format_bytes = GST_FORMAT_BYTES;
gint64 duration, size;
/* try to estimate the average bitrate */
2012-03-05 12:36:39 +00:00
if (gst_pad_peer_query_duration (GST_AUDIO_DECODER_SINK_PAD (dec),
format_bytes, &size) &&
gst_pad_peer_query_duration (GST_AUDIO_DECODER_SINK_PAD (dec),
format_time, &duration) && size > 0 && duration > 0) {
guint64 bitrate;
2012-03-05 12:36:39 +00:00
list = gst_tag_list_new_empty ();
2012-02-27 22:46:03 +00:00
bitrate = gst_util_uint64_scale (size, 8 * GST_SECOND, duration);
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE, GST_TAG_BITRATE,
(guint) bitrate, NULL);
gst_audio_decoder_merge_tags (GST_AUDIO_DECODER (dec), list,
GST_TAG_MERGE_REPLACE);
gst_tag_list_unref (list);
2012-02-27 22:46:03 +00:00
}
}
static GstFlowReturn
2012-02-27 22:46:03 +00:00
gst_wavpack_dec_handle_frame (GstAudioDecoder * bdec, GstBuffer * buf)
{
GstWavpackDec *dec;
GstBuffer *outbuf = NULL;
GstFlowReturn ret = GST_FLOW_OK;
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
WavpackHeader wph;
int32_t decoded, unpacked_size;
gboolean format_changed;
gint width, depth, i, j, max, wavpack_mode;
gboolean mode_float;
gint32 *dec_data = NULL;
guint8 *out_data;
2012-03-05 12:36:39 +00:00
GstMapInfo map, omap;
2012-02-27 22:46:03 +00:00
dec = GST_WAVPACK_DEC (bdec);
g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
2012-03-05 12:36:39 +00:00
gst_buffer_map (buf, &map, GST_MAP_READ);
/* check input, we only accept framed input with complete chunks */
2012-03-05 12:36:39 +00:00
if (map.size < sizeof (WavpackHeader))
goto input_not_framed;
2012-03-05 12:36:39 +00:00
if (!gst_wavpack_read_header (&wph, map.data))
goto invalid_header;
2012-03-05 12:36:39 +00:00
if (map.size < wph.ckSize + 4 * 1 + 4)
ext/wavpack/: Add support for encoding, parsing and decoding multichannel files with up to 8 channels. This also impr... Original commit message from CVS: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_get_default_channel_mask), (gst_wavpack_set_channel_layout), (gst_wavpack_get_default_channel_positions), (gst_wavpack_get_channel_mask_from_positions), (gst_wavpack_set_channel_mapping): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), (gst_wavpack_dec_sink_set_caps), (gst_wavpack_dec_chain): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_reset), (gst_wavpack_enc_init), (gst_wavpack_enc_sink_set_caps), (gst_wavpack_enc_set_wp_config), (gst_wavpack_enc_push_block), (gst_wavpack_enc_fix_channel_order), (gst_wavpack_enc_chain), (gst_wavpack_enc_rewrite_first_block), (gst_wavpack_enc_sink_event): * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_index_append_entry), (gst_wavpack_parse_reset), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_sink_event), (gst_wavpack_parse_create_src_pad), (gst_wavpack_parse_push_buffer), (gst_wavpack_parse_loop): * ext/wavpack/gstwavpackparse.h: Add support for encoding, parsing and decoding multichannel files with up to 8 channels. This also improves the robustness of parsing quite a bit. * ext/wavpack/gstwavpackstreamreader.c: (gst_wavpack_stream_reader_read_bytes), (gst_wavpack_stream_reader_get_pos), (gst_wavpack_stream_reader_set_pos_abs), (gst_wavpack_stream_reader_set_pos_rel), (gst_wavpack_stream_reader_push_back_byte), (gst_wavpack_stream_reader_get_length), (gst_wavpack_stream_reader_can_seek), (gst_wavpack_stream_reader_write_bytes): Improve debugging.
2007-11-20 13:08:45 +00:00
goto input_not_framed;
if (!(wph.flags & INITIAL_BLOCK))
goto input_not_framed;
2012-03-05 12:36:39 +00:00
dec->wv_id.buffer = map.data;
dec->wv_id.length = map.size;
dec->wv_id.position = 0;
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
/* create a new wavpack context if there is none yet but if there
* was already one (i.e. caps were set on the srcpad) check whether
* the new one has the same caps */
if (!dec->context) {
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
gchar error_msg[80];
dec->context = WavpackOpenFileInputEx (dec->stream_reader,
&dec->wv_id, NULL, error_msg, OPEN_STREAMING, 0);
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
2012-02-27 22:46:03 +00:00
/* expect this to work */
if (!dec->context) {
2012-02-27 22:46:03 +00:00
GST_WARNING_OBJECT (dec, "Couldn't decode buffer: %s", error_msg);
goto context_failed;
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
}
}
g_assert (dec->context != NULL);
wavpack_mode = WavpackGetMode (dec->context);
mode_float = (wavpack_mode & MODE_FLOAT) == MODE_FLOAT;
format_changed =
(dec->sample_rate != WavpackGetSampleRate (dec->context)) ||
(dec->channels != WavpackGetNumChannels (dec->context)) ||
(dec->depth != WavpackGetBytesPerSample (dec->context) * 8) ||
(dec->mode_float != mode_float) ||
ext/wavpack/: Add support for encoding, parsing and decoding multichannel files with up to 8 channels. This also impr... Original commit message from CVS: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_get_default_channel_mask), (gst_wavpack_set_channel_layout), (gst_wavpack_get_default_channel_positions), (gst_wavpack_get_channel_mask_from_positions), (gst_wavpack_set_channel_mapping): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), (gst_wavpack_dec_sink_set_caps), (gst_wavpack_dec_chain): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_reset), (gst_wavpack_enc_init), (gst_wavpack_enc_sink_set_caps), (gst_wavpack_enc_set_wp_config), (gst_wavpack_enc_push_block), (gst_wavpack_enc_fix_channel_order), (gst_wavpack_enc_chain), (gst_wavpack_enc_rewrite_first_block), (gst_wavpack_enc_sink_event): * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_index_append_entry), (gst_wavpack_parse_reset), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_sink_event), (gst_wavpack_parse_create_src_pad), (gst_wavpack_parse_push_buffer), (gst_wavpack_parse_loop): * ext/wavpack/gstwavpackparse.h: Add support for encoding, parsing and decoding multichannel files with up to 8 channels. This also improves the robustness of parsing quite a bit. * ext/wavpack/gstwavpackstreamreader.c: (gst_wavpack_stream_reader_read_bytes), (gst_wavpack_stream_reader_get_pos), (gst_wavpack_stream_reader_set_pos_abs), (gst_wavpack_stream_reader_set_pos_rel), (gst_wavpack_stream_reader_push_back_byte), (gst_wavpack_stream_reader_get_length), (gst_wavpack_stream_reader_can_seek), (gst_wavpack_stream_reader_write_bytes): Improve debugging.
2007-11-20 13:08:45 +00:00
(dec->channel_mask != WavpackGetChannelMask (dec->context));
2012-03-05 12:36:39 +00:00
if (!gst_pad_has_current_caps (GST_AUDIO_DECODER_SRC_PAD (dec)) ||
format_changed) {
ext/wavpack/: Add support for encoding, parsing and decoding multichannel files with up to 8 channels. This also impr... Original commit message from CVS: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_get_default_channel_mask), (gst_wavpack_set_channel_layout), (gst_wavpack_get_default_channel_positions), (gst_wavpack_get_channel_mask_from_positions), (gst_wavpack_set_channel_mapping): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), (gst_wavpack_dec_sink_set_caps), (gst_wavpack_dec_chain): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_reset), (gst_wavpack_enc_init), (gst_wavpack_enc_sink_set_caps), (gst_wavpack_enc_set_wp_config), (gst_wavpack_enc_push_block), (gst_wavpack_enc_fix_channel_order), (gst_wavpack_enc_chain), (gst_wavpack_enc_rewrite_first_block), (gst_wavpack_enc_sink_event): * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_index_append_entry), (gst_wavpack_parse_reset), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_sink_event), (gst_wavpack_parse_create_src_pad), (gst_wavpack_parse_push_buffer), (gst_wavpack_parse_loop): * ext/wavpack/gstwavpackparse.h: Add support for encoding, parsing and decoding multichannel files with up to 8 channels. This also improves the robustness of parsing quite a bit. * ext/wavpack/gstwavpackstreamreader.c: (gst_wavpack_stream_reader_read_bytes), (gst_wavpack_stream_reader_get_pos), (gst_wavpack_stream_reader_set_pos_abs), (gst_wavpack_stream_reader_set_pos_rel), (gst_wavpack_stream_reader_push_back_byte), (gst_wavpack_stream_reader_get_length), (gst_wavpack_stream_reader_can_seek), (gst_wavpack_stream_reader_write_bytes): Improve debugging.
2007-11-20 13:08:45 +00:00
gint channel_mask;
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
dec->sample_rate = WavpackGetSampleRate (dec->context);
dec->channels = WavpackGetNumChannels (dec->context);
dec->depth = WavpackGetBytesPerSample (dec->context) * 8;
dec->mode_float = mode_float;
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
ext/wavpack/: Add support for encoding, parsing and decoding multichannel files with up to 8 channels. This also impr... Original commit message from CVS: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_get_default_channel_mask), (gst_wavpack_set_channel_layout), (gst_wavpack_get_default_channel_positions), (gst_wavpack_get_channel_mask_from_positions), (gst_wavpack_set_channel_mapping): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), (gst_wavpack_dec_sink_set_caps), (gst_wavpack_dec_chain): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_reset), (gst_wavpack_enc_init), (gst_wavpack_enc_sink_set_caps), (gst_wavpack_enc_set_wp_config), (gst_wavpack_enc_push_block), (gst_wavpack_enc_fix_channel_order), (gst_wavpack_enc_chain), (gst_wavpack_enc_rewrite_first_block), (gst_wavpack_enc_sink_event): * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_index_append_entry), (gst_wavpack_parse_reset), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_sink_event), (gst_wavpack_parse_create_src_pad), (gst_wavpack_parse_push_buffer), (gst_wavpack_parse_loop): * ext/wavpack/gstwavpackparse.h: Add support for encoding, parsing and decoding multichannel files with up to 8 channels. This also improves the robustness of parsing quite a bit. * ext/wavpack/gstwavpackstreamreader.c: (gst_wavpack_stream_reader_read_bytes), (gst_wavpack_stream_reader_get_pos), (gst_wavpack_stream_reader_set_pos_abs), (gst_wavpack_stream_reader_set_pos_rel), (gst_wavpack_stream_reader_push_back_byte), (gst_wavpack_stream_reader_get_length), (gst_wavpack_stream_reader_can_seek), (gst_wavpack_stream_reader_write_bytes): Improve debugging.
2007-11-20 13:08:45 +00:00
channel_mask = WavpackGetChannelMask (dec->context);
if (channel_mask == 0)
channel_mask = gst_wavpack_get_default_channel_mask (dec->channels);
dec->channel_mask = channel_mask;
2012-02-27 22:46:03 +00:00
gst_wavpack_dec_negotiate (dec);
/* send GST_TAG_AUDIO_CODEC and GST_TAG_BITRATE tags before something
* is decoded or after the format has changed */
ext/wavpack/: Don't play audioconvert. As wavpack wants/outputs all samples with width==32 and depth=[1,32] accept th... Original commit message from CVS: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), (gst_wavpack_dec_init), (gst_wavpack_dec_sink_set_caps), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_post_tags), (gst_wavpack_dec_chain): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_reset), (gst_wavpack_enc_sink_set_caps), (gst_wavpack_enc_set_wp_config), (gst_wavpack_enc_chain): * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.c: Don't play audioconvert. As wavpack wants/outputs all samples with width==32 and depth=[1,32] accept this and let audioconvert convert to accepted formats instead of doing it in the element for n*8 depths. This also adds support for non-n*8 depths and prevents some useless memory allocations. Fixes #421598 Also add a workaround for bug #421542 in wavpackenc for now... * tests/check/elements/wavpackdec.c: (GST_START_TEST): * tests/check/elements/wavpackenc.c: (GST_START_TEST): * tests/check/elements/wavpackparse.c: (GST_START_TEST): Consider the change above in the unit tests and test if the correct caps are accepted and set. Also check for GST_BUFFER_OFFSET_END in the wavpackparse unit test. * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_init), (gst_wavpack_dec_sink_set_caps): Set caps on the src pad as soon as possible. * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.h: Fix indention. gst-indent is now called by cicl.
2007-03-30 04:50:11 +00:00
gst_wavpack_dec_post_tags (dec);
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
}
/* alloc output buffer */
dec_data = g_malloc (4 * wph.block_samples * dec->channels);
ext/wavpack/: Don't play audioconvert. As wavpack wants/outputs all samples with width==32 and depth=[1,32] accept th... Original commit message from CVS: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), (gst_wavpack_dec_init), (gst_wavpack_dec_sink_set_caps), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_post_tags), (gst_wavpack_dec_chain): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_reset), (gst_wavpack_enc_sink_set_caps), (gst_wavpack_enc_set_wp_config), (gst_wavpack_enc_chain): * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.c: Don't play audioconvert. As wavpack wants/outputs all samples with width==32 and depth=[1,32] accept this and let audioconvert convert to accepted formats instead of doing it in the element for n*8 depths. This also adds support for non-n*8 depths and prevents some useless memory allocations. Fixes #421598 Also add a workaround for bug #421542 in wavpackenc for now... * tests/check/elements/wavpackdec.c: (GST_START_TEST): * tests/check/elements/wavpackenc.c: (GST_START_TEST): * tests/check/elements/wavpackparse.c: (GST_START_TEST): Consider the change above in the unit tests and test if the correct caps are accepted and set. Also check for GST_BUFFER_OFFSET_END in the wavpackparse unit test. * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_init), (gst_wavpack_dec_sink_set_caps): Set caps on the src pad as soon as possible. * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.h: Fix indention. gst-indent is now called by cicl.
2007-03-30 04:50:11 +00:00
/* decode */
decoded = WavpackUnpackSamples (dec->context, dec_data, wph.block_samples);
ext/wavpack/: Don't play audioconvert. As wavpack wants/outputs all samples with width==32 and depth=[1,32] accept th... Original commit message from CVS: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_reset), (gst_wavpack_dec_init), (gst_wavpack_dec_sink_set_caps), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_post_tags), (gst_wavpack_dec_chain): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_reset), (gst_wavpack_enc_sink_set_caps), (gst_wavpack_enc_set_wp_config), (gst_wavpack_enc_chain): * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.c: Don't play audioconvert. As wavpack wants/outputs all samples with width==32 and depth=[1,32] accept this and let audioconvert convert to accepted formats instead of doing it in the element for n*8 depths. This also adds support for non-n*8 depths and prevents some useless memory allocations. Fixes #421598 Also add a workaround for bug #421542 in wavpackenc for now... * tests/check/elements/wavpackdec.c: (GST_START_TEST): * tests/check/elements/wavpackenc.c: (GST_START_TEST): * tests/check/elements/wavpackparse.c: (GST_START_TEST): Consider the change above in the unit tests and test if the correct caps are accepted and set. Also check for GST_BUFFER_OFFSET_END in the wavpackparse unit test. * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_init), (gst_wavpack_dec_sink_set_caps): Set caps on the src pad as soon as possible. * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackenc.h: * ext/wavpack/gstwavpackparse.h: Fix indention. gst-indent is now called by cicl.
2007-03-30 04:50:11 +00:00
if (decoded != wph.block_samples)
goto decode_error;
2012-03-05 12:36:39 +00:00
unpacked_size = (dec->width / 8) * wph.block_samples * dec->channels;
outbuf = gst_buffer_new_and_alloc (unpacked_size);
/* legacy; pass along offset, whatever that might entail */
GST_BUFFER_OFFSET (outbuf) = GST_BUFFER_OFFSET (buf);
gst_buffer_map (outbuf, &omap, GST_MAP_WRITE);
out_data = omap.data;
width = dec->width;
depth = dec->depth;
max = dec->channels * wph.block_samples;
if (width == 8) {
gint8 *outbuffer = (gint8 *) out_data;
2012-03-05 12:36:39 +00:00
gint *reorder_map = dec->channel_reorder_map;
2012-03-05 12:36:39 +00:00
for (i = 0; i < max; i += dec->channels) {
for (j = 0; j < dec->channels; j++)
*outbuffer++ = (gint8) (dec_data[i + reorder_map[j]]);
}
} else if (width == 16) {
gint16 *outbuffer = (gint16 *) out_data;
2012-03-05 12:36:39 +00:00
gint *reorder_map = dec->channel_reorder_map;
2012-03-05 12:36:39 +00:00
for (i = 0; i < max; i += dec->channels) {
for (j = 0; j < dec->channels; j++)
*outbuffer++ = (gint16) (dec_data[i + reorder_map[j]]);
}
} else if (dec->width == 32) {
gint32 *outbuffer = (gint32 *) out_data;
2012-03-05 12:36:39 +00:00
gint *reorder_map = dec->channel_reorder_map;
if (width != depth) {
2012-03-05 12:36:39 +00:00
for (i = 0; i < max; i += dec->channels) {
for (j = 0; j < dec->channels; j++)
*outbuffer++ =
(gint32) (dec_data[i + reorder_map[j]] << (width - depth));
}
} else {
2012-03-05 12:36:39 +00:00
for (i = 0; i < max; i += dec->channels) {
for (j = 0; j < dec->channels; j++)
*outbuffer++ = (gint32) (dec_data[i + reorder_map[j]]);
}
}
} else {
g_assert_not_reached ();
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
}
ext/wavpack/gstwavpackdec.c: Add debug category, use boilerplate macros, fix handling of widths of 32 bits. Original commit message from CVS: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_setcaps), (gst_wavpack_dec_base_init), (gst_wavpack_dec_dispose), (gst_wavpack_dec_class_init), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_init), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_chain), (gst_wavpack_dec_plugin_init): Add debug category, use boilerplate macros, fix handling of widths of 32 bits. * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_dispose), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_last_entry), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_index_append_entry), (gst_wavpack_parse_reset), (gst_wavpack_parse_src_query), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_send_newsegment), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_src_event), (gst_wavpack_parse_init), (gst_wavpack_parse_get_upstream_length), (gst_wavpack_parse_pull_buffer), (gst_wavpack_parse_create_src_pad), (gst_wavpack_parse_loop), (gst_wavpack_parse_change_state), (gst_wavepack_parse_sink_activate), (gst_wavepack_parse_sink_activate_pull), (gst_wavpack_parse_plugin_init): * ext/wavpack/gstwavpackparse.h: Rewrite a bit, mostly to fix flow logic and to make seeking work. Fix buffer/event refcounting. Add some debug statements. Add width of 32 to source pad template caps. Use boilerplate macros.
2006-01-29 20:07:49 +00:00
2012-03-05 12:36:39 +00:00
gst_buffer_unmap (outbuf, &omap);
gst_buffer_unmap (buf, &map);
buf = NULL;
g_free (dec_data);
2012-02-27 22:46:03 +00:00
ret = gst_audio_decoder_finish_frame (bdec, outbuf, 1);
ext/wavpack/gstwavpackdec.c: Add debug category, use boilerplate macros, fix handling of widths of 32 bits. Original commit message from CVS: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_setcaps), (gst_wavpack_dec_base_init), (gst_wavpack_dec_dispose), (gst_wavpack_dec_class_init), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_init), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_chain), (gst_wavpack_dec_plugin_init): Add debug category, use boilerplate macros, fix handling of widths of 32 bits. * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_dispose), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_last_entry), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_index_append_entry), (gst_wavpack_parse_reset), (gst_wavpack_parse_src_query), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_send_newsegment), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_src_event), (gst_wavpack_parse_init), (gst_wavpack_parse_get_upstream_length), (gst_wavpack_parse_pull_buffer), (gst_wavpack_parse_create_src_pad), (gst_wavpack_parse_loop), (gst_wavpack_parse_change_state), (gst_wavepack_parse_sink_activate), (gst_wavepack_parse_sink_activate_pull), (gst_wavpack_parse_plugin_init): * ext/wavpack/gstwavpackparse.h: Rewrite a bit, mostly to fix flow logic and to make seeking work. Fix buffer/event refcounting. Add some debug statements. Add width of 32 to source pad template caps. Use boilerplate macros.
2006-01-29 20:07:49 +00:00
out:
2012-03-05 12:36:39 +00:00
if (buf)
gst_buffer_unmap (buf, &map);
if (G_UNLIKELY (ret != GST_FLOW_OK)) {
GST_DEBUG_OBJECT (dec, "flow: %s", gst_flow_get_name (ret));
}
configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. Original commit message from CVS: Patch by: Sebastian Dröge <slomo at circular-chaos.org> * configure.ac: Check for wavpack version and define WAVPACK_OLD_API if necessary. * ext/wavpack/Makefile.am: * ext/wavpack/gstwavpackcommon.c: (gst_wavpack_read_header), (gst_wavpack_read_metadata): * ext/wavpack/gstwavpackcommon.h: * ext/wavpack/gstwavpackdec.c: (gst_wavpack_dec_base_init), (gst_wavpack_dec_class_init), (gst_wavpack_dec_init), (gst_wavpack_dec_finalize), (gst_wavpack_dec_format_samples), (gst_wavpack_dec_clip_outgoing_buffer), (gst_wavpack_dec_chain), (gst_wavpack_dec_sink_event), (gst_wavpack_dec_change_state), (gst_wavpack_dec_request_new_pad), (gst_wavpack_dec_plugin_init): * ext/wavpack/gstwavpackdec.h: * ext/wavpack/gstwavpackenc.c: (gst_wavpack_enc_class_init), (gst_wavpack_enc_init), (gst_wavpack_enc_finalize), (gst_wavpack_enc_set_wp_config): * ext/wavpack/gstwavpackparse.c: (gst_wavpack_parse_base_init), (gst_wavpack_parse_finalize), (gst_wavpack_parse_class_init), (gst_wavpack_parse_index_get_entry_from_sample), (gst_wavpack_parse_scan_to_find_sample), (gst_wavpack_parse_handle_seek_event), (gst_wavpack_parse_create_src_pad): * ext/wavpack/gstwavpackstreamreader.c: * ext/wavpack/gstwavpackstreamreader.h: Port to new/official wavpack API, don't use API that was exported in wavpack header files and in the lib but meant to be private, at least not for recent wavpack versions; misc. 'cleanups' (#347443).
2006-07-18 14:08:06 +00:00
return ret;
/* ERRORS */
input_not_framed:
{
GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL), ("Expected framed input"));
2012-03-05 12:36:39 +00:00
ret = GST_FLOW_ERROR;
goto out;
}
invalid_header:
{
GST_ELEMENT_ERROR (dec, STREAM, DECODE, (NULL), ("Invalid wavpack header"));
2012-03-05 12:36:39 +00:00
ret = GST_FLOW_ERROR;
goto out;
}
2012-02-27 22:46:03 +00:00
context_failed:
{
GST_AUDIO_DECODER_ERROR (bdec, 1, LIBRARY, INIT, (NULL),
("error creating Wavpack context"), ret);
goto out;
}
decode_error:
{
const gchar *reason = "unknown";
if (dec->context) {
reason = WavpackGetErrorMessage (dec->context);
} else {
reason = "couldn't create decoder context";
}
2012-02-27 22:46:03 +00:00
GST_AUDIO_DECODER_ERROR (bdec, 1, STREAM, DECODE, (NULL),
("decoding error: %s", reason), ret);
g_free (dec_data);
2012-02-27 22:46:03 +00:00
if (ret == GST_FLOW_OK)
gst_audio_decoder_finish_frame (bdec, NULL, 1);
2012-03-05 12:36:39 +00:00
goto out;
}
}