mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 01:30:38 +00:00
8dd45c0027
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).
106 lines
2.8 KiB
C
106 lines
2.8 KiB
C
/* GStreamer Wavpack plugin
|
|
* Copyright (c) 2006 Sebastian Dröge <slomo@circular-chaos.org>
|
|
*
|
|
* gstwavpackstreamreader.c: stream reader used for decoding
|
|
*
|
|
* 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.
|
|
*/
|
|
|
|
#include <string.h>
|
|
#include <math.h>
|
|
#include <gst/gst.h>
|
|
|
|
#include "gstwavpackstreamreader.h"
|
|
|
|
static int32_t
|
|
gst_wavpack_stream_reader_read_bytes (void *id, void *data, int32_t bcount)
|
|
{
|
|
read_id *rid = (read_id *) id;
|
|
uint32_t left = rid->length - rid->position;
|
|
uint32_t to_read = MIN (left, bcount);
|
|
|
|
if (to_read > 0) {
|
|
g_memmove (data, rid->buffer + rid->position, to_read);
|
|
rid->position += to_read;
|
|
return to_read;
|
|
} else {
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
static uint32_t
|
|
gst_wavpack_stream_reader_get_pos (void *id)
|
|
{
|
|
return ((read_id *) id)->position;
|
|
}
|
|
|
|
static int
|
|
gst_wavpack_stream_reader_set_pos_abs (void *id, uint32_t pos)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
static int
|
|
gst_wavpack_stream_reader_set_pos_rel (void *id, int32_t delta, int mode)
|
|
{
|
|
return -1;
|
|
}
|
|
|
|
static int
|
|
gst_wavpack_stream_reader_push_back_byte (void *id, int c)
|
|
{
|
|
read_id *rid = (read_id *) id;
|
|
|
|
rid->position -= 1;
|
|
if (rid->position < 0)
|
|
rid->position = 0;
|
|
return rid->position;
|
|
}
|
|
|
|
static uint32_t
|
|
gst_wavpack_stream_reader_get_length (void *id)
|
|
{
|
|
return ((read_id *) id)->length;
|
|
}
|
|
|
|
static int
|
|
gst_wavpack_stream_reader_can_seek (void *id)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
static int32_t
|
|
gst_wavpack_stream_reader_write_bytes (void *id, void *data, int32_t bcount)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
WavpackStreamReader *
|
|
gst_wavpack_stream_reader_new ()
|
|
{
|
|
WavpackStreamReader *stream_reader =
|
|
(WavpackStreamReader *) g_malloc0 (sizeof (WavpackStreamReader));
|
|
stream_reader->read_bytes = gst_wavpack_stream_reader_read_bytes;
|
|
stream_reader->get_pos = gst_wavpack_stream_reader_get_pos;
|
|
stream_reader->set_pos_abs = gst_wavpack_stream_reader_set_pos_abs;
|
|
stream_reader->set_pos_rel = gst_wavpack_stream_reader_set_pos_rel;
|
|
stream_reader->push_back_byte = gst_wavpack_stream_reader_push_back_byte;
|
|
stream_reader->get_length = gst_wavpack_stream_reader_get_length;
|
|
stream_reader->can_seek = gst_wavpack_stream_reader_can_seek;
|
|
stream_reader->write_bytes = gst_wavpack_stream_reader_write_bytes;
|
|
|
|
return stream_reader;
|
|
}
|