diff options
author | Sebastian Dröge <slomo@circular-chaos.org> | 2006-07-18 14:08:06 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.net> | 2006-07-18 14:08:06 +0000 |
commit | 8dd45c0027604b6ff82807760da7a77da4e1b4b6 (patch) | |
tree | b2d863cff7cbeb7ecfc5c4fc5fbb4280a347ea2c /ext/wavpack/gstwavpackcommon.c | |
parent | 4071cd900f58791470a1f569122297190ca0b790 (diff) | |
download | gst-plugins-bad-8dd45c0027604b6ff82807760da7a77da4e1b4b6.tar.gz gst-plugins-bad-8dd45c0027604b6ff82807760da7a77da4e1b4b6.tar.bz2 gst-plugins-bad-8dd45c0027604b6ff82807760da7a77da4e1b4b6.zip |
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).
Diffstat (limited to 'ext/wavpack/gstwavpackcommon.c')
-rw-r--r-- | ext/wavpack/gstwavpackcommon.c | 87 |
1 files changed, 84 insertions, 3 deletions
diff --git a/ext/wavpack/gstwavpackcommon.c b/ext/wavpack/gstwavpackcommon.c index 61c8add0..0272fdf0 100644 --- a/ext/wavpack/gstwavpackcommon.c +++ b/ext/wavpack/gstwavpackcommon.c @@ -1,3 +1,30 @@ +/* GStreamer Wavpack plugin + * Copyright (c) 2005 Arwed v. Merkatz <v.merkatz@gmx.net> + * Copyright (c) 1998 - 2005 Conifer Software + * Copyright (c) 2006 Sebastian Dröge <slomo@circular-chaos.org> + * + * gstwavpackcommon.c: common helper functions + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "gstwavpackcommon.h" #include <string.h> @@ -5,10 +32,64 @@ gboolean gst_wavpack_read_header (WavpackHeader * header, guint8 * buf) { g_memmove (header, buf, sizeof (WavpackHeader)); + +#ifndef WAVPACK_OLD_API + WavpackLittleEndianToNative (header, WavpackHeaderFormat); +#else little_endian_to_native (header, WavpackHeaderFormat); +#endif + + return (memcmp (header->ckID, "wvpk", 4) == 0); +} - if (strncmp (header->ckID, "wvpk", 4)) +/* inspired by the original one in wavpack */ +gboolean +gst_wavpack_read_metadata (GstWavpackMetadata * wpmd, guint8 * header_data, + guint8 ** p_data) +{ + WavpackHeader hdr; + guint8 *end; + + gst_wavpack_read_header (&hdr, header_data); + end = header_data + hdr.ckSize + 8; + + if (end - *p_data < 2) return FALSE; - else - return TRUE; + + wpmd->id = GST_READ_UINT8 (*p_data); + wpmd->byte_length = 2 * (guint) GST_READ_UINT8 (*p_data + 1); + + *p_data += 2; + + if ((wpmd->id & ID_LARGE) == ID_LARGE) { + guint extra; + + wpmd->id &= ~ID_LARGE; + + if (end - *p_data < 2) + return FALSE; + + extra = GST_READ_UINT16_LE (*p_data); + wpmd->byte_length += (extra << 9); + *p_data += 2; + } + + if ((wpmd->id & ID_ODD_SIZE) == ID_ODD_SIZE) { + wpmd->id &= ~ID_ODD_SIZE; + --wpmd->byte_length; + } + + if (wpmd->byte_length > 0) { + if (end - *p_data < wpmd->byte_length + (wpmd->byte_length & 1)) { + wpmd->data = NULL; + return FALSE; + } + + wpmd->data = *p_data; + *p_data += wpmd->byte_length + (wpmd->byte_length & 1); + } else { + wpmd->data = NULL; + } + + return TRUE; } |