mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 11:45:25 +00:00
Add FLAC parser, based on GstBaseParse. Also add the bit and byte reader that will be added to libgstbase later.
Original commit message from CVS: * configure.ac: * gst/flacparse/Makefile.am: * gst/flacparse/gstbaseparse.c: (gst_base_parse_get_type), (gst_base_parse_base_init), (gst_base_parse_base_finalize), (gst_base_parse_finalize), (gst_base_parse_class_init), (gst_base_parse_init), (gst_base_parse_check_frame), (gst_base_parse_parse_frame), (gst_base_parse_bytepos_to_time), (gst_base_parse_sink_event), (gst_base_parse_sink_eventfunc), (gst_base_parse_src_event), (gst_base_parse_src_eventfunc), (gst_base_parse_is_seekable), (gst_base_parse_push_buffer), (gst_base_parse_handle_and_push_buffer), (gst_base_parse_drain), (gst_base_parse_chain), (gst_base_parse_pull_range), (gst_base_parse_loop), (gst_base_parse_sink_activate), (gst_base_parse_activate), (gst_base_parse_sink_activate_push), (gst_base_parse_sink_activate_pull), (gst_base_parse_set_duration), (gst_base_parse_set_min_frame_size), (gst_base_parse_get_querytypes), (gst_base_parse_query), (gst_base_parse_handle_seek), (gst_base_parse_sink_setcaps): * gst/flacparse/gstbaseparse.h: * gst/flacparse/gstbitreader.c: (gst_bit_reader_new), (gst_bit_reader_new_from_buffer), (gst_bit_reader_free), (gst_bit_reader_init), (gst_bit_reader_init_from_buffer), (gst_bit_reader_set_pos), (gst_bit_reader_get_pos), (gst_bit_reader_get_remaining), (gst_bit_reader_skip), (gst_bit_reader_skip_to_byte): * gst/flacparse/gstbitreader.h: * gst/flacparse/gstbytereader.c: (GDOUBLE_SWAP_LE_BE), (GFLOAT_SWAP_LE_BE), (gst_byte_reader_new), (gst_byte_reader_new_from_buffer), (gst_byte_reader_free), (gst_byte_reader_init), (gst_byte_reader_init_from_buffer), (gst_byte_reader_set_pos), (gst_byte_reader_get_pos), (gst_byte_reader_get_remaining), (gst_byte_reader_skip), (gst_byte_reader_get_uint8), (gst_byte_reader_get_int8), (gst_byte_reader_peek_uint8), (gst_byte_reader_peek_int8), (gst_byte_reader_get_uint24_le), (gst_byte_reader_get_uint24_be), (gst_byte_reader_get_int24_le), (gst_byte_reader_get_int24_be), (gst_byte_reader_peek_uint24_le), (gst_byte_reader_peek_uint24_be), (gst_byte_reader_peek_int24_le), (gst_byte_reader_peek_int24_be): * gst/flacparse/gstbytereader.h: * gst/flacparse/gstflac.c: (plugin_init): * gst/flacparse/gstflacparse.c: (gst_flac_parse_base_init), (gst_flac_parse_class_init), (gst_flac_parse_init), (gst_flac_parse_finalize), (gst_flac_parse_start), (gst_flac_parse_stop), (gst_flac_parse_get_frame_size), (gst_flac_parse_check_valid_frame), (gst_flac_parse_handle_streaminfo), (gst_flac_parse_handle_vorbiscomment), (gst_flac_parse_handle_picture), (_value_array_append_buffer), (gst_flac_parse_handle_headers), (gst_flac_parse_generate_headers), (gst_flac_parse_parse_frame): * gst/flacparse/gstflacparse.h: Add FLAC parser, based on GstBaseParse. Also add the bit and byte reader that will be added to libgstbase later. The FLAC parser is currently not 100% bug free and fails to get the correct frame size for some frames in some streams.
This commit is contained in:
parent
a8736df9b5
commit
ba0a1f60ed
12 changed files with 5309 additions and 0 deletions
59
ChangeLog
59
ChangeLog
|
@ -1,3 +1,62 @@
|
|||
2008-09-29 Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
||||
|
||||
* configure.ac:
|
||||
* gst/flacparse/Makefile.am:
|
||||
* gst/flacparse/gstbaseparse.c: (gst_base_parse_get_type),
|
||||
(gst_base_parse_base_init), (gst_base_parse_base_finalize),
|
||||
(gst_base_parse_finalize), (gst_base_parse_class_init),
|
||||
(gst_base_parse_init), (gst_base_parse_check_frame),
|
||||
(gst_base_parse_parse_frame), (gst_base_parse_bytepos_to_time),
|
||||
(gst_base_parse_sink_event), (gst_base_parse_sink_eventfunc),
|
||||
(gst_base_parse_src_event), (gst_base_parse_src_eventfunc),
|
||||
(gst_base_parse_is_seekable), (gst_base_parse_push_buffer),
|
||||
(gst_base_parse_handle_and_push_buffer), (gst_base_parse_drain),
|
||||
(gst_base_parse_chain), (gst_base_parse_pull_range),
|
||||
(gst_base_parse_loop), (gst_base_parse_sink_activate),
|
||||
(gst_base_parse_activate), (gst_base_parse_sink_activate_push),
|
||||
(gst_base_parse_sink_activate_pull), (gst_base_parse_set_duration),
|
||||
(gst_base_parse_set_min_frame_size),
|
||||
(gst_base_parse_get_querytypes), (gst_base_parse_query),
|
||||
(gst_base_parse_handle_seek), (gst_base_parse_sink_setcaps):
|
||||
* gst/flacparse/gstbaseparse.h:
|
||||
* gst/flacparse/gstbitreader.c: (gst_bit_reader_new),
|
||||
(gst_bit_reader_new_from_buffer), (gst_bit_reader_free),
|
||||
(gst_bit_reader_init), (gst_bit_reader_init_from_buffer),
|
||||
(gst_bit_reader_set_pos), (gst_bit_reader_get_pos),
|
||||
(gst_bit_reader_get_remaining), (gst_bit_reader_skip),
|
||||
(gst_bit_reader_skip_to_byte):
|
||||
* gst/flacparse/gstbitreader.h:
|
||||
* gst/flacparse/gstbytereader.c: (GDOUBLE_SWAP_LE_BE),
|
||||
(GFLOAT_SWAP_LE_BE), (gst_byte_reader_new),
|
||||
(gst_byte_reader_new_from_buffer), (gst_byte_reader_free),
|
||||
(gst_byte_reader_init), (gst_byte_reader_init_from_buffer),
|
||||
(gst_byte_reader_set_pos), (gst_byte_reader_get_pos),
|
||||
(gst_byte_reader_get_remaining), (gst_byte_reader_skip),
|
||||
(gst_byte_reader_get_uint8), (gst_byte_reader_get_int8),
|
||||
(gst_byte_reader_peek_uint8), (gst_byte_reader_peek_int8),
|
||||
(gst_byte_reader_get_uint24_le), (gst_byte_reader_get_uint24_be),
|
||||
(gst_byte_reader_get_int24_le), (gst_byte_reader_get_int24_be),
|
||||
(gst_byte_reader_peek_uint24_le), (gst_byte_reader_peek_uint24_be),
|
||||
(gst_byte_reader_peek_int24_le), (gst_byte_reader_peek_int24_be):
|
||||
* gst/flacparse/gstbytereader.h:
|
||||
* gst/flacparse/gstflac.c: (plugin_init):
|
||||
* gst/flacparse/gstflacparse.c: (gst_flac_parse_base_init),
|
||||
(gst_flac_parse_class_init), (gst_flac_parse_init),
|
||||
(gst_flac_parse_finalize), (gst_flac_parse_start),
|
||||
(gst_flac_parse_stop), (gst_flac_parse_get_frame_size),
|
||||
(gst_flac_parse_check_valid_frame),
|
||||
(gst_flac_parse_handle_streaminfo),
|
||||
(gst_flac_parse_handle_vorbiscomment),
|
||||
(gst_flac_parse_handle_picture), (_value_array_append_buffer),
|
||||
(gst_flac_parse_handle_headers), (gst_flac_parse_generate_headers),
|
||||
(gst_flac_parse_parse_frame):
|
||||
* gst/flacparse/gstflacparse.h:
|
||||
Add FLAC parser, based on GstBaseParse. Also add the bit and byte reader
|
||||
that will be added to libgstbase later.
|
||||
|
||||
The FLAC parser is currently not 100% bug free and fails to get the
|
||||
correct frame size for some frames in some streams.
|
||||
|
||||
2008-09-27 Jan Schmidt <jan.schmidt@sun.com>
|
||||
|
||||
* ext/resindvd/gstmpegdemux.c:
|
||||
|
|
|
@ -251,6 +251,8 @@ AG_GST_CHECK_PLUGIN(deinterlace2)
|
|||
AG_GST_CHECK_PLUGIN(dvdspu)
|
||||
AG_GST_CHECK_PLUGIN(festival)
|
||||
AG_GST_CHECK_PLUGIN(filter)
|
||||
AG_GST_CHECK_PLUGIN(flacparse)
|
||||
AG_GST_CHECK_PLUGIN(flacparse)
|
||||
AG_GST_CHECK_PLUGIN(flv)
|
||||
AG_GST_CHECK_PLUGIN(freeze)
|
||||
AG_GST_CHECK_PLUGIN(h264parse)
|
||||
|
@ -1403,6 +1405,7 @@ gst/deinterlace2/Makefile
|
|||
gst/dvdspu/Makefile
|
||||
gst/festival/Makefile
|
||||
gst/filter/Makefile
|
||||
gst/flacparse/Makefile
|
||||
gst/flv/Makefile
|
||||
gst/freeze/Makefile
|
||||
gst/h264parse/Makefile
|
||||
|
|
11
gst/flacparse/Makefile.am
Normal file
11
gst/flacparse/Makefile.am
Normal file
|
@ -0,0 +1,11 @@
|
|||
plugin_LTLIBRARIES = libgstflacparse.la
|
||||
|
||||
libgstflacparse_la_SOURCES = gstflac.c gstbaseparse.c gstflacparse.c gstbitreader.c gstbytereader.c
|
||||
libgstflacparse_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_BASE_CFLAGS) $(GST_CFLAGS)
|
||||
libgstflacparse_la_LIBADD = \
|
||||
$(GST_PLUGINS_BASE_LIBS) -lgsttag-$(GST_MAJORMINOR) \
|
||||
-lgstaudio-$(GST_MAJORMINOR) \
|
||||
$(GST_BASE_LIBS) $(GST_LIBS)
|
||||
libgstflacparse_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||
|
||||
noinst_HEADERS = gstbitreader.h gstbytereader.h gstbaseparse.h gstflacparse.h
|
1763
gst/flacparse/gstbaseparse.c
Normal file
1763
gst/flacparse/gstbaseparse.c
Normal file
File diff suppressed because it is too large
Load diff
237
gst/flacparse/gstbaseparse.h
Normal file
237
gst/flacparse/gstbaseparse.h
Normal file
|
@ -0,0 +1,237 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 2008 Nokia Corporation. All rights reserved.
|
||||
*
|
||||
* Contact: Stefan Kost <stefan.kost@nokia.com>
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GST_BASE_PARSE_H__
|
||||
#define __GST_BASE_PARSE_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include <gst/base/gstadapter.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_BASE_PARSE (gst_base_parse_get_type())
|
||||
#define GST_BASE_PARSE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_BASE_PARSE,GstBaseParse))
|
||||
#define GST_BASE_PARSE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_BASE_PARSE,GstBaseParseClass))
|
||||
#define GST_BASE_PARSE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_BASE_PARSE,GstBaseParseClass))
|
||||
#define GST_IS_BASE_PARSE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_BASE_PARSE))
|
||||
#define GST_IS_BASE_PARSE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_BASE_PARSE))
|
||||
#define GST_BASE_PARSE_CAST(obj) ((GstBaseParse *)(obj))
|
||||
|
||||
/**
|
||||
* GST_BASE_PARSE_SINK_NAME:
|
||||
*
|
||||
* the name of the templates for the sink pad
|
||||
*/
|
||||
#define GST_BASE_PARSE_SINK_NAME "sink"
|
||||
/**
|
||||
* GST_BASE_PARSE_SRC_NAME:
|
||||
*
|
||||
* the name of the templates for the source pad
|
||||
*/
|
||||
#define GST_BASE_PARSE_SRC_NAME "src"
|
||||
|
||||
/**
|
||||
* GST_BASE_PARSE_SRC_PAD:
|
||||
* @obj: base parse instance
|
||||
*
|
||||
* Gives the pointer to the source #GstPad object of the element.
|
||||
*
|
||||
* Since: 0.10.x
|
||||
*/
|
||||
#define GST_BASE_PARSE_SRC_PAD(obj) (GST_BASE_PARSE_CAST (obj)->srcpad)
|
||||
|
||||
/**
|
||||
* GST_BASE_PARSE_SINK_PAD:
|
||||
* @obj: base parse instance
|
||||
*
|
||||
* Gives the pointer to the sink #GstPad object of the element.
|
||||
*
|
||||
* Since: 0.10.x
|
||||
*/
|
||||
#define GST_BASE_PARSE_SINK_PAD(obj) (GST_BASE_PARSE_CAST (obj)->sinkpad)
|
||||
|
||||
/**
|
||||
* GST_BASE_PARSE_FLOW_DROPPED:
|
||||
*
|
||||
* A #GstFlowReturn that can be returned from parse_frame to
|
||||
* indicate that no output buffer was generated.
|
||||
*
|
||||
* Since: 0.10.x
|
||||
*/
|
||||
#define GST_BASE_PARSE_FLOW_DROPPED GST_FLOW_CUSTOM_SUCCESS
|
||||
|
||||
/**
|
||||
* GST_BASE_PARSE_LOCK:
|
||||
* @obj: base parse instance
|
||||
*
|
||||
* Obtain a lock to protect the parse function from concurrent access.
|
||||
*
|
||||
* Since: 0.10.x
|
||||
*/
|
||||
#define GST_BASE_PARSE_LOCK(obj) g_mutex_lock (GST_BASE_PARSE_CAST (obj)->parse_lock)
|
||||
|
||||
/**
|
||||
* GST_BASE_PARSE_UNLOCK:
|
||||
* @obj: base parse instance
|
||||
*
|
||||
* Release the lock that protects the parse function from concurrent access.
|
||||
*
|
||||
* Since: 0.10.x
|
||||
*/
|
||||
#define GST_BASE_PARSE_UNLOCK(obj) g_mutex_unlock (GST_BASE_PARSE_CAST (obj)->parse_lock)
|
||||
|
||||
typedef struct _GstBaseParse GstBaseParse;
|
||||
typedef struct _GstBaseParseClass GstBaseParseClass;
|
||||
typedef struct _GstBaseParsePrivate GstBaseParsePrivate;
|
||||
typedef struct _GstBaseParseClassPrivate GstBaseParseClassPrivate;
|
||||
|
||||
/**
|
||||
* GstBaseParse:
|
||||
* @element: the parent element.
|
||||
*
|
||||
* The opaque #GstBaseParse data structure.
|
||||
*/
|
||||
struct _GstBaseParse {
|
||||
GstElement element;
|
||||
|
||||
/*< protected >*/
|
||||
/* source and sink pads */
|
||||
GstPad *sinkpad;
|
||||
GstPad *srcpad;
|
||||
|
||||
/* MT-protected (with STREAM_LOCK) */
|
||||
GstSegment segment;
|
||||
|
||||
/* Newsegment event to be sent after SEEK */
|
||||
GstEvent *pending_segment;
|
||||
|
||||
/* Segment event that closes the running segment prior to SEEK */
|
||||
GstEvent *close_segment;
|
||||
|
||||
/* Caps nego done already? */
|
||||
gboolean negotiated;
|
||||
|
||||
GMutex *parse_lock;
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE];
|
||||
GstBaseParsePrivate *priv;
|
||||
};
|
||||
|
||||
/**
|
||||
* GstBaseParseClass:
|
||||
* @start: Optional.
|
||||
* Called when the element starts processing.
|
||||
* Allows opening external resources.
|
||||
* @stop: Optional.
|
||||
* Called when the element stops processing.
|
||||
* Allows closing external resources.
|
||||
* @set_sink_caps: allows the subclass to be notified of the actual caps set.
|
||||
* @check_valid_frame: Check if the given piece of data contains a valid
|
||||
* frame.
|
||||
* @parse_frame: Parse the already checked frame. Subclass need to
|
||||
* set the buffer timestamp, duration, caps and possibly
|
||||
* other necessary metadata. This is called with srcpad's
|
||||
* STREAM_LOCK held.
|
||||
* @convert: Optional.
|
||||
* Convert between formats.
|
||||
* @find_frame: Optional.
|
||||
* Finds a frame. Gets a position passed and should return
|
||||
* TRUE and the offset in bytes where this position is.
|
||||
* Will only be called in pull mode and the subclass can pull
|
||||
* whatever it wants from upstream. If not implemented,
|
||||
* the base class will implement it by calling
|
||||
* @check_valid_frame and @parse_frame to find the wanted
|
||||
* frame and build a seek table.
|
||||
* @event: Optional.
|
||||
* Event handler on the sink pad. This function should return
|
||||
* TRUE if the event was handled and can be dropped.
|
||||
* @src_event: Optional.
|
||||
* Event handler on the source pad. Should return TRUE
|
||||
* if the event was handled and can be dropped.
|
||||
* @is_seekable: Optional.
|
||||
* Subclass can override this if it wants to control the
|
||||
* seekability of the stream. Otherwise the element assumes
|
||||
* that stream is always seekable.
|
||||
*
|
||||
* Subclasses can override any of the available virtual methods or not, as
|
||||
* needed. At minimum @check_valid_frame and @parse_frame needs to be
|
||||
* overridden.
|
||||
*/
|
||||
struct _GstBaseParseClass {
|
||||
GstElementClass parent_class;
|
||||
|
||||
/*< public >*/
|
||||
/* virtual methods for subclasses */
|
||||
|
||||
gboolean (*start) (GstBaseParse *parse);
|
||||
|
||||
gboolean (*stop) (GstBaseParse *parse);
|
||||
|
||||
gboolean (*set_sink_caps) (GstBaseParse *parse,
|
||||
GstCaps *caps);
|
||||
|
||||
gboolean (*check_valid_frame) (GstBaseParse *parse,
|
||||
GstBuffer *buffer,
|
||||
guint *framesize,
|
||||
gint *skipsize);
|
||||
|
||||
GstFlowReturn (*parse_frame) (GstBaseParse *parse,
|
||||
GstBuffer *buffer);
|
||||
|
||||
gboolean (*convert) (GstBaseParse * parse,
|
||||
GstFormat src_format,
|
||||
gint64 src_value,
|
||||
GstFormat dest_format,
|
||||
gint64 * dest_value);
|
||||
|
||||
gboolean (*find_frame) (GstBaseParse *parse,
|
||||
GstFormat src_format,
|
||||
gint64 src_value,
|
||||
gint64 * dest_value);
|
||||
|
||||
gboolean (*event) (GstBaseParse *parse,
|
||||
GstEvent *event);
|
||||
|
||||
gboolean (*src_event) (GstBaseParse *parse,
|
||||
GstEvent *event);
|
||||
|
||||
gboolean (*is_seekable) (GstBaseParse *parse);
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE];
|
||||
GstBaseParseClassPrivate *priv;
|
||||
};
|
||||
|
||||
GType gst_base_parse_get_type (void);
|
||||
|
||||
GstFlowReturn gst_base_parse_push_buffer (GstBaseParse *parse, GstBuffer *buffer);
|
||||
|
||||
void gst_base_parse_set_duration (GstBaseParse *parse,
|
||||
GstFormat fmt,
|
||||
gint64 duration);
|
||||
|
||||
void gst_base_parse_set_min_frame_size (GstBaseParse *parse,
|
||||
guint min_size);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_BASE_PARSE_H__ */
|
400
gst/flacparse/gstbitreader.c
Normal file
400
gst/flacparse/gstbitreader.c
Normal file
|
@ -0,0 +1,400 @@
|
|||
/* GStreamer
|
||||
*
|
||||
* Copyright (C) 2008 Sebastian Dröge <sebastian.droege@collabora.co.uk>.
|
||||
*
|
||||
* 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 "gstbitreader.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* SECTION:gstbitreader
|
||||
* @short_description: Reads any number of bits from a memory buffer
|
||||
*
|
||||
* #GstBitReader provides a bit reader that can read any number of bits
|
||||
* from a memory buffer. It provides functions for reading any number of bits
|
||||
* into 8, 16, 32 and 64 bit variables.
|
||||
*/
|
||||
|
||||
/**
|
||||
* gst_bit_reader_new:
|
||||
* @data: Data from which the #GstBitReader should read
|
||||
* @size: Size of @data in bytes
|
||||
*
|
||||
* Create a new #GstBitReader instance, which will read from @data.
|
||||
*
|
||||
* Returns: a new #GstBitReader instance
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
GstBitReader *
|
||||
gst_bit_reader_new (const guint8 * data, guint size)
|
||||
{
|
||||
GstBitReader *ret = g_slice_new0 (GstBitReader);
|
||||
|
||||
ret->data = data;
|
||||
ret->size = size;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_reader_new_from_buffer:
|
||||
* @buffer: Buffer from which the #GstBitReader should read
|
||||
*
|
||||
* Create a new #GstBitReader instance, which will read from the
|
||||
* #GstBuffer @buffer.
|
||||
*
|
||||
* Returns: a new #GstBitReader instance
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
GstBitReader *
|
||||
gst_bit_reader_new_from_buffer (const GstBuffer * buffer)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_BUFFER (buffer), NULL);
|
||||
|
||||
return gst_bit_reader_new (GST_BUFFER_DATA (buffer),
|
||||
GST_BUFFER_SIZE (buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_reader_free:
|
||||
* @reader: a #GstBitReader instance
|
||||
*
|
||||
* Frees a #GstBitReader instance, which was previously allocated by
|
||||
* gst_bit_reader_new() or gst_bit_reader_new_from_buffer().
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
void
|
||||
gst_bit_reader_free (GstBitReader * reader)
|
||||
{
|
||||
g_return_if_fail (reader != NULL);
|
||||
|
||||
g_slice_free (GstBitReader, reader);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_reader_init:
|
||||
* @reader: a #GstBitReader instance
|
||||
* @data: Data from which the #GstBitReader should read
|
||||
* @size: Size of @data in bytes
|
||||
*
|
||||
* Initializes a #GstBitReader instance to read from @data. This function
|
||||
* can be called on already initialized instances.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
void
|
||||
gst_bit_reader_init (GstBitReader * reader, const guint8 * data, guint size)
|
||||
{
|
||||
g_return_if_fail (reader != NULL);
|
||||
|
||||
reader->data = data;
|
||||
reader->size = size;
|
||||
reader->byte = reader->bit = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_reader_init:
|
||||
* @reader: a #GstBitReader instance
|
||||
* @buffer: Buffer from which the #GstBitReader should read
|
||||
*
|
||||
* Initializes a #GstBitReader instance to read from @buffer. This function
|
||||
* can be called on already initialized instances.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
void
|
||||
gst_bit_reader_init_from_buffer (GstBitReader * reader,
|
||||
const GstBuffer * buffer)
|
||||
{
|
||||
g_return_if_fail (GST_IS_BUFFER (buffer));
|
||||
|
||||
gst_bit_reader_init (reader, GST_BUFFER_DATA (buffer),
|
||||
GST_BUFFER_SIZE (buffer));
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_reader_set_pos:
|
||||
* @reader: a #GstBitReader instance
|
||||
* @pos: The new position in bits
|
||||
*
|
||||
* Sets the new position of a #GstBitReader instance to @pos in bits.
|
||||
*
|
||||
* Returns: %TRUE if the position could be set successfully, %FALSE
|
||||
* otherwise.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
gboolean
|
||||
gst_bit_reader_set_pos (GstBitReader * reader, guint pos)
|
||||
{
|
||||
g_return_val_if_fail (reader != NULL, FALSE);
|
||||
|
||||
if (pos > reader->size * 8)
|
||||
return FALSE;
|
||||
|
||||
reader->byte = pos / 8;
|
||||
reader->bit = pos % 8;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_reader_get_pos:
|
||||
* @reader: a #GstBitReader instance
|
||||
*
|
||||
* Returns the current position of a #GstBitReader instance in bits.
|
||||
*
|
||||
* Returns: The current position of @reader in bits.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
guint
|
||||
gst_bit_reader_get_pos (const GstBitReader * reader)
|
||||
{
|
||||
g_return_val_if_fail (reader != NULL, 0);
|
||||
|
||||
return reader->byte * 8 + reader->bit;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_reader_get_remaining:
|
||||
* @reader: a #GstBitReader instance
|
||||
*
|
||||
* Returns the remaining number of bits of a #GstBitReader instance.
|
||||
*
|
||||
* Returns: The remaining number of bits of @reader instance.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
guint
|
||||
gst_bit_reader_get_remaining (const GstBitReader * reader)
|
||||
{
|
||||
g_return_val_if_fail (reader != NULL, 0);
|
||||
|
||||
return reader->size * 8 - (reader->byte * 8 + reader->bit);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_reader_skip:
|
||||
* @reader: a #GstBitReader instance
|
||||
* @nbits: the number of bits to skip
|
||||
*
|
||||
* Skips @nbits bits of the #GstBitReader instance.
|
||||
*
|
||||
* Returns: %TRUE if @nbits bits could be skipped, %FALSE otherwise.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
gboolean
|
||||
gst_bit_reader_skip (GstBitReader * reader, guint nbits)
|
||||
{
|
||||
g_return_val_if_fail (reader != NULL, FALSE);
|
||||
|
||||
if (gst_bit_reader_get_remaining (reader) < nbits)
|
||||
return FALSE;
|
||||
|
||||
reader->bit += nbits;
|
||||
reader->byte += reader->bit / 8;
|
||||
reader->bit = reader->bit % 8;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_reader_skip_to_byte:
|
||||
* @reader: a #GstBitReader instance
|
||||
*
|
||||
* Skips until the next byte.
|
||||
*
|
||||
* Returns: %TRUE if successful, %FALSE otherwise.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
gboolean
|
||||
gst_bit_reader_skip_to_byte (GstBitReader * reader)
|
||||
{
|
||||
g_return_val_if_fail (reader != NULL, FALSE);
|
||||
|
||||
if (reader->byte > reader->size)
|
||||
return FALSE;
|
||||
|
||||
if (reader->bit) {
|
||||
reader->bit = 0;
|
||||
reader->byte++;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_bit_reader_get_bits_uint8:
|
||||
* @reader: a #GstBitReader instance
|
||||
* @val: Pointer to a #guint8 to store the result
|
||||
* @nbits: number of bits to read
|
||||
*
|
||||
* Read @nbits bits into @val and update the current position.
|
||||
*
|
||||
* Returns: %TRUE if successful, %FALSE otherwise.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
|
||||
/**
|
||||
* gst_bit_reader_get_bits_uint16:
|
||||
* @reader: a #GstBitReader instance
|
||||
* @val: Pointer to a #guint16 to store the result
|
||||
* @nbits: number of bits to read
|
||||
*
|
||||
* Read @nbits bits into @val and update the current position.
|
||||
*
|
||||
* Returns: %TRUE if successful, %FALSE otherwise.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
|
||||
/**
|
||||
* gst_bit_reader_get_bits_uint32:
|
||||
* @reader: a #GstBitReader instance
|
||||
* @val: Pointer to a #guint32 to store the result
|
||||
* @nbits: number of bits to read
|
||||
*
|
||||
* Read @nbits bits into @val and update the current position.
|
||||
*
|
||||
* Returns: %TRUE if successful, %FALSE otherwise.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
|
||||
/**
|
||||
* gst_bit_reader_get_bits_uint64:
|
||||
* @reader: a #GstBitReader instance
|
||||
* @val: Pointer to a #guint64 to store the result
|
||||
* @nbits: number of bits to read
|
||||
*
|
||||
* Read @nbits bits into @val and update the current position.
|
||||
*
|
||||
* Returns: %TRUE if successful, %FALSE otherwise.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
|
||||
/**
|
||||
* gst_bit_reader_peek_bits_uint8:
|
||||
* @reader: a #GstBitReader instance
|
||||
* @val: Pointer to a #guint8 to store the result
|
||||
* @nbits: number of bits to read
|
||||
*
|
||||
* Read @nbits bits into @val but keep the current position.
|
||||
*
|
||||
* Returns: %TRUE if successful, %FALSE otherwise.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
|
||||
/**
|
||||
* gst_bit_reader_peek_bits_uint16:
|
||||
* @reader: a #GstBitReader instance
|
||||
* @val: Pointer to a #guint16 to store the result
|
||||
* @nbits: number of bits to read
|
||||
*
|
||||
* Read @nbits bits into @val but keep the current position.
|
||||
*
|
||||
* Returns: %TRUE if successful, %FALSE otherwise.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
|
||||
/**
|
||||
* gst_bit_reader_peek_bits_uint32:
|
||||
* @reader: a #GstBitReader instance
|
||||
* @val: Pointer to a #guint32 to store the result
|
||||
* @nbits: number of bits to read
|
||||
*
|
||||
* Read @nbits bits into @val but keep the current position.
|
||||
*
|
||||
* Returns: %TRUE if successful, %FALSE otherwise.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
|
||||
/**
|
||||
* gst_bit_reader_peek_bits_uint64:
|
||||
* @reader: a #GstBitReader instance
|
||||
* @val: Pointer to a #guint64 to store the result
|
||||
* @nbits: number of bits to read
|
||||
*
|
||||
* Read @nbits bits into @val but keep the current position.
|
||||
*
|
||||
* Returns: %TRUE if successful, %FALSE otherwise.
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
|
||||
#define GST_BIT_READER_READ_BITS(bits) \
|
||||
gboolean \
|
||||
gst_bit_reader_get_bits_uint##bits (GstBitReader *reader, guint##bits *val, guint nbits) \
|
||||
{ \
|
||||
guint##bits ret = 0; \
|
||||
\
|
||||
g_return_val_if_fail (reader != NULL, FALSE); \
|
||||
g_return_val_if_fail (val != NULL, FALSE); \
|
||||
g_return_val_if_fail (nbits <= bits, FALSE); \
|
||||
\
|
||||
if (reader->byte * 8 + reader->bit + nbits > reader->size * 8) \
|
||||
return FALSE; \
|
||||
\
|
||||
while (nbits > 0) { \
|
||||
guint toread = MIN (nbits, 8 - reader->bit); \
|
||||
\
|
||||
ret <<= toread; \
|
||||
ret |= (reader->data[reader->byte] & (0xff >> reader->bit)) >> (8 - toread - reader->bit); \
|
||||
\
|
||||
reader->bit += toread; \
|
||||
if (reader->bit >= 8) { \
|
||||
reader->byte++; \
|
||||
reader->bit = 0; \
|
||||
} \
|
||||
nbits -= toread; \
|
||||
} \
|
||||
\
|
||||
*val = ret; \
|
||||
return TRUE; \
|
||||
} \
|
||||
\
|
||||
gboolean \
|
||||
gst_bit_reader_peek_bits_uint##bits (const GstBitReader *reader, guint##bits *val, guint nbits) \
|
||||
{ \
|
||||
GstBitReader tmp; \
|
||||
\
|
||||
g_return_val_if_fail (reader != NULL, FALSE); \
|
||||
tmp = *reader; \
|
||||
return gst_bit_reader_get_bits_uint##bits (&tmp, val, nbits); \
|
||||
}
|
||||
|
||||
GST_BIT_READER_READ_BITS (8);
|
||||
GST_BIT_READER_READ_BITS (16);
|
||||
GST_BIT_READER_READ_BITS (32);
|
||||
GST_BIT_READER_READ_BITS (64);
|
99
gst/flacparse/gstbitreader.h
Normal file
99
gst/flacparse/gstbitreader.h
Normal file
|
@ -0,0 +1,99 @@
|
|||
/* GStreamer
|
||||
*
|
||||
* Copyright (C) 2008 Sebastian Dröge <sebastian.droege@collabora.co.uk>.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GST_BIT_READER_H__
|
||||
#define __GST_BIT_READER_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* GstBitReader:
|
||||
* @data: Data from which the bit reader will read
|
||||
* @size: Size of @data in bytes
|
||||
* @byte: Current byte position
|
||||
* @bit: Bit position in the current byte
|
||||
*
|
||||
* A bit reader instance.
|
||||
*/
|
||||
typedef struct {
|
||||
const guint8 *data;
|
||||
guint size;
|
||||
|
||||
guint byte; /* Byte position */
|
||||
guint bit; /* Bit position in the current byte */
|
||||
} GstBitReader;
|
||||
|
||||
GstBitReader * gst_bit_reader_new (const guint8 *data, guint size);
|
||||
GstBitReader * gst_bit_reader_new_from_buffer (const GstBuffer *buffer);
|
||||
void gst_bit_reader_free (GstBitReader *reader);
|
||||
|
||||
void gst_bit_reader_init (GstBitReader *reader, const guint8 *data, guint size);
|
||||
void gst_bit_reader_init_from_buffer (GstBitReader *reader, const GstBuffer *buffer);
|
||||
|
||||
gboolean gst_bit_reader_set_pos (GstBitReader *reader, guint pos);
|
||||
|
||||
guint gst_bit_reader_get_pos (const GstBitReader *reader);
|
||||
guint gst_bit_reader_get_remaining (const GstBitReader *reader);
|
||||
|
||||
gboolean gst_bit_reader_skip (GstBitReader *reader, guint nbits);
|
||||
gboolean gst_bit_reader_skip_to_byte (GstBitReader *reader);
|
||||
|
||||
gboolean gst_bit_reader_get_bits_uint8 (GstBitReader *reader, guint8 *val, guint nbits);
|
||||
gboolean gst_bit_reader_get_bits_uint16 (GstBitReader *reader, guint16 *val, guint nbits);
|
||||
gboolean gst_bit_reader_get_bits_uint32 (GstBitReader *reader, guint32 *val, guint nbits);
|
||||
gboolean gst_bit_reader_get_bits_uint64 (GstBitReader *reader, guint64 *val, guint nbits);
|
||||
|
||||
gboolean gst_bit_reader_peek_bits_uint8 (const GstBitReader *reader, guint8 *val, guint nbits);
|
||||
gboolean gst_bit_reader_peek_bits_uint16 (const GstBitReader *reader, guint16 *val, guint nbits);
|
||||
gboolean gst_bit_reader_peek_bits_uint32 (const GstBitReader *reader, guint32 *val, guint nbits);
|
||||
gboolean gst_bit_reader_peek_bits_uint64 (const GstBitReader *reader, guint64 *val, guint nbits);
|
||||
|
||||
/**
|
||||
* GST_BIT_READER_INIT:
|
||||
* @data: Data from which the #GstBitReader should read
|
||||
* @size: Size of @data in bytes
|
||||
*
|
||||
* A #GstBitReader must be initialized with this macro, before it can be
|
||||
* used. This macro can used be to initialize a variable, but it cannot
|
||||
* be assigned to a variable. In that case you have to use
|
||||
* gst_bit_reader_init().
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
#define GST_BIT_READER_INIT(data, size) {data, size, 0, 0}
|
||||
|
||||
/**
|
||||
* GST_BIT_READER_INIT_FROM_BUFFER:
|
||||
* @buffer: Buffer from which the #GstBitReader should read
|
||||
*
|
||||
* A #GstBitReader must be initialized with this macro, before it can be
|
||||
* used. This macro can used be to initialize a variable, but it cannot
|
||||
* be assigned to a variable. In that case you have to use
|
||||
* gst_bit_reader_init().
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
#define GST_BIT_READER_INIT_FROM_BUFFER(buffer) {GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer), 0, 0}
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_BIT_READER_H__ */
|
1231
gst/flacparse/gstbytereader.c
Normal file
1231
gst/flacparse/gstbytereader.c
Normal file
File diff suppressed because it is too large
Load diff
134
gst/flacparse/gstbytereader.h
Normal file
134
gst/flacparse/gstbytereader.h
Normal file
|
@ -0,0 +1,134 @@
|
|||
/* GStreamer
|
||||
*
|
||||
* Copyright (C) 2008 Sebastian Dröge <sebastian.droege@collabora.co.uk>.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GST_BYTE_READER_H__
|
||||
#define __GST_BYTE_READER_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* GstByteReader:
|
||||
* @data: Data from which the bit reader will read
|
||||
* @size: Size of @data in bytes
|
||||
* @byte: Current byte position
|
||||
*
|
||||
* A byte reader instance.
|
||||
*/
|
||||
typedef struct {
|
||||
const guint8 *data;
|
||||
guint size;
|
||||
|
||||
guint byte; /* Byte position */
|
||||
} GstByteReader;
|
||||
|
||||
GstByteReader * gst_byte_reader_new (const guint8 *data, guint size);
|
||||
GstByteReader * gst_byte_reader_new_from_buffer (const GstBuffer *buffer);
|
||||
void gst_byte_reader_free (GstByteReader *reader);
|
||||
|
||||
void gst_byte_reader_init (GstByteReader *reader, const guint8 *data, guint size);
|
||||
void gst_byte_reader_init_from_buffer (GstByteReader *reader, const GstBuffer *buffer);
|
||||
|
||||
gboolean gst_byte_reader_set_pos (GstByteReader *reader, guint pos);
|
||||
|
||||
guint gst_byte_reader_get_pos (const GstByteReader *reader);
|
||||
guint gst_byte_reader_get_remaining (const GstByteReader *reader);
|
||||
|
||||
gboolean gst_byte_reader_skip (GstByteReader *reader, guint nbytes);
|
||||
|
||||
gboolean gst_byte_reader_get_uint8 (GstByteReader *reader, guint8 *val);
|
||||
gboolean gst_byte_reader_get_int8 (GstByteReader *reader, gint8 *val);
|
||||
gboolean gst_byte_reader_get_uint16_le (GstByteReader *reader, guint16 *val);
|
||||
gboolean gst_byte_reader_get_int16_le (GstByteReader *reader, gint16 *val);
|
||||
gboolean gst_byte_reader_get_uint16_be (GstByteReader *reader, guint16 *val);
|
||||
gboolean gst_byte_reader_get_int16_be (GstByteReader *reader, gint16 *val);
|
||||
gboolean gst_byte_reader_get_uint24_le (GstByteReader *reader, guint32 *val);
|
||||
gboolean gst_byte_reader_get_int24_le (GstByteReader *reader, gint32 *val);
|
||||
gboolean gst_byte_reader_get_uint24_be (GstByteReader *reader, guint32 *val);
|
||||
gboolean gst_byte_reader_get_int24_be (GstByteReader *reader, gint32 *val);
|
||||
gboolean gst_byte_reader_get_uint32_le (GstByteReader *reader, guint32 *val);
|
||||
gboolean gst_byte_reader_get_int32_le (GstByteReader *reader, gint32 *val);
|
||||
gboolean gst_byte_reader_get_uint32_be (GstByteReader *reader, guint32 *val);
|
||||
gboolean gst_byte_reader_get_int32_be (GstByteReader *reader, gint32 *val);
|
||||
gboolean gst_byte_reader_get_uint64_le (GstByteReader *reader, guint64 *val);
|
||||
gboolean gst_byte_reader_get_int64_le (GstByteReader *reader, gint64 *val);
|
||||
gboolean gst_byte_reader_get_uint64_be (GstByteReader *reader, guint64 *val);
|
||||
gboolean gst_byte_reader_get_int64_be (GstByteReader *reader, gint64 *val);
|
||||
|
||||
gboolean gst_byte_reader_peek_uint8 (GstByteReader *reader, guint8 *val);
|
||||
gboolean gst_byte_reader_peek_int8 (GstByteReader *reader, gint8 *val);
|
||||
gboolean gst_byte_reader_peek_uint16_le (GstByteReader *reader, guint16 *val);
|
||||
gboolean gst_byte_reader_peek_int16_le (GstByteReader *reader, gint16 *val);
|
||||
gboolean gst_byte_reader_peek_uint16_be (GstByteReader *reader, guint16 *val);
|
||||
gboolean gst_byte_reader_peek_int16_be (GstByteReader *reader, gint16 *val);
|
||||
gboolean gst_byte_reader_peek_uint24_le (GstByteReader *reader, guint32 *val);
|
||||
gboolean gst_byte_reader_peek_int24_le (GstByteReader *reader, gint32 *val);
|
||||
gboolean gst_byte_reader_peek_uint24_be (GstByteReader *reader, guint32 *val);
|
||||
gboolean gst_byte_reader_peek_int24_be (GstByteReader *reader, gint32 *val);
|
||||
gboolean gst_byte_reader_peek_uint32_le (GstByteReader *reader, guint32 *val);
|
||||
gboolean gst_byte_reader_peek_int32_le (GstByteReader *reader, gint32 *val);
|
||||
gboolean gst_byte_reader_peek_uint32_be (GstByteReader *reader, guint32 *val);
|
||||
gboolean gst_byte_reader_peek_int32_be (GstByteReader *reader, gint32 *val);
|
||||
gboolean gst_byte_reader_peek_uint64_le (GstByteReader *reader, guint64 *val);
|
||||
gboolean gst_byte_reader_peek_int64_le (GstByteReader *reader, gint64 *val);
|
||||
gboolean gst_byte_reader_peek_uint64_be (GstByteReader *reader, guint64 *val);
|
||||
gboolean gst_byte_reader_peek_int64_be (GstByteReader *reader, gint64 *val);
|
||||
|
||||
gboolean gst_byte_reader_get_float32_le (GstByteReader *reader, gfloat *val);
|
||||
gboolean gst_byte_reader_get_float32_be (GstByteReader *reader, gfloat *val);
|
||||
gboolean gst_byte_reader_get_float64_le (GstByteReader *reader, gdouble *val);
|
||||
gboolean gst_byte_reader_get_float64_be (GstByteReader *reader, gdouble *val);
|
||||
|
||||
gboolean gst_byte_reader_peek_float32_le (GstByteReader *reader, gfloat *val);
|
||||
gboolean gst_byte_reader_peek_float32_be (GstByteReader *reader, gfloat *val);
|
||||
gboolean gst_byte_reader_peek_float64_le (GstByteReader *reader, gdouble *val);
|
||||
gboolean gst_byte_reader_peek_float64_be (GstByteReader *reader, gdouble *val);
|
||||
|
||||
/**
|
||||
* GST_BYTE_READER_INIT:
|
||||
* @data: Data from which the #GstByteReader should read
|
||||
* @size: Size of @data in bytes
|
||||
*
|
||||
* A #GstByteReader must be initialized with this macro, before it can be
|
||||
* used. This macro can used be to initialize a variable, but it cannot
|
||||
* be assigned to a variable. In that case you have to use
|
||||
* gst_byte_reader_init().
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
#define GST_BYTE_READER_INIT(data, size) {data, size, 0}
|
||||
|
||||
/**
|
||||
* GST_BYTE_READER_INIT_FROM_BUFFER:
|
||||
* @buffer: Buffer from which the #GstByteReader should read
|
||||
*
|
||||
* A #GstByteReader must be initialized with this macro, before it can be
|
||||
* used. This macro can used be to initialize a variable, but it cannot
|
||||
* be assigned to a variable. In that case you have to use
|
||||
* gst_byte_reader_init().
|
||||
*
|
||||
* Since: 0.10.22
|
||||
*/
|
||||
#define GST_BYTE_READER_INIT_FROM_BUFFER(buffer) {GST_BUFFER_DATA (buffer), GST_BUFFER_SIZE (buffer), 0}
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_BYTE_READER_H__ */
|
52
gst/flacparse/gstflac.c
Normal file
52
gst/flacparse/gstflac.c
Normal file
|
@ -0,0 +1,52 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||
*
|
||||
* 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 "gstflacparse.h"
|
||||
|
||||
#include <gst/tag/tag.h>
|
||||
#include <gst/gst-i18n-plugin.h>
|
||||
|
||||
static gboolean
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
#if ENABLE_NLS
|
||||
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
|
||||
LOCALEDIR);
|
||||
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
||||
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||
#endif
|
||||
|
||||
if (!gst_element_register (plugin, "flacparse", GST_RANK_NONE,
|
||||
gst_flac_parse_get_type ()))
|
||||
return FALSE;
|
||||
|
||||
gst_tag_register_musicbrainz_tags ();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||
GST_VERSION_MINOR,
|
||||
"flacparse",
|
||||
"The FLAC Lossless compressor Codec parser",
|
||||
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|
1233
gst/flacparse/gstflacparse.c
Normal file
1233
gst/flacparse/gstflacparse.c
Normal file
File diff suppressed because it is too large
Load diff
87
gst/flacparse/gstflacparse.h
Normal file
87
gst/flacparse/gstflacparse.h
Normal file
|
@ -0,0 +1,87 @@
|
|||
/* GStreamer
|
||||
*
|
||||
* Copyright (C) 2008 Sebastian Dröge <sebastian.droege@collabora.co.uk>.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __GST_FLAC_PARSE_H__
|
||||
#define __GST_FLAC_PARSE_H__
|
||||
|
||||
#include <gst/gst.h>
|
||||
#include "gstbaseparse.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define GST_TYPE_FLAC_PARSE (gst_base_parse_get_type())
|
||||
#define GST_FLAC_PARSE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FLAC_PARSE,GstFlacParse))
|
||||
#define GST_FLAC_PARSE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FLAC_PARSE,GstFlacParseClass))
|
||||
#define GST_FLAC_PARSE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_FLAC_PARSE,GstFlacParseClass))
|
||||
#define GST_IS_FLAC_PARSE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FLAC_PARSE))
|
||||
#define GST_IS_FLAC_PARSE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FLAC_PARSE))
|
||||
#define GST_FLAC_PARSE_CAST(obj) ((GstFlacParse *)(obj))
|
||||
|
||||
typedef struct _GstFlacParse GstFlacParse;
|
||||
typedef struct _GstFlacParseClass GstFlacParseClass;
|
||||
|
||||
typedef enum {
|
||||
GST_FLAC_PARSE_STATE_INIT,
|
||||
GST_FLAC_PARSE_STATE_HEADERS,
|
||||
GST_FLAC_PARSE_STATE_GENERATE_HEADERS,
|
||||
GST_FLAC_PARSE_STATE_DATA
|
||||
} GstFlacParseState;
|
||||
|
||||
typedef struct {
|
||||
guint8 type;
|
||||
} GstFlacParseSubFrame;
|
||||
|
||||
struct _GstFlacParse {
|
||||
GstBaseParse parent;
|
||||
|
||||
GstFlacParseState state;
|
||||
|
||||
gint64 upstream_length;
|
||||
|
||||
/* STREAMINFO content */
|
||||
guint16 min_blocksize, max_blocksize;
|
||||
guint32 min_framesize, max_framesize;
|
||||
guint32 samplerate;
|
||||
guint8 channels;
|
||||
guint8 bps;
|
||||
guint64 total_samples;
|
||||
|
||||
guint requested_frame_size;
|
||||
|
||||
/* Current frame */
|
||||
guint64 offset;
|
||||
guint8 blocking_strategy;
|
||||
guint16 block_size;
|
||||
guint64 sample_number;
|
||||
|
||||
GstTagList *tags;
|
||||
|
||||
GList *headers;
|
||||
};
|
||||
|
||||
struct _GstFlacParseClass {
|
||||
GstBaseParseClass parent_class;
|
||||
};
|
||||
|
||||
GType gst_flac_parse_get_type (void);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_FLAC_PARSE_H__ */
|
Loading…
Reference in a new issue