2 * Copyright (C) 2010 Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
3 * Copyright (C) 2010 Nokia Corporation. All rights reserved.
4 * Contact: Stefan Kost <stefan.kost@nokia.com>
6 * Tremor modifications <2006>:
7 * Chris Lord, OpenedHand Ltd. <chris@openedhand.com>, http://www.o-hand.com/
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
19 * You should have received a copy of the GNU Library General Public
20 * License along with this library; if not, write to the
21 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 * Boston, MA 02111-1307, USA.
25 #ifndef __GST_VORBIS_DEC_LIB_H__
26 #define __GST_VORBIS_DEC_LIB_H__
32 #include <vorbis/codec.h>
34 typedef float vorbis_sample_t;
35 typedef ogg_packet ogg_packet_wrapper;
37 #define GST_VORBIS_DEC_DESCRIPTION "decode raw vorbis streams to float audio"
39 #define GST_VORBIS_DEC_SRC_CAPS \
40 GST_STATIC_CAPS ("audio/x-raw-float, " \
41 "rate = (int) [ 1, MAX ], " \
42 "channels = (int) [ 1, 256 ], " \
43 "endianness = (int) BYTE_ORDER, " \
46 #define GST_VORBIS_DEC_DEFAULT_SAMPLE_WIDTH (32)
48 #define GST_VORBIS_DEC_GLIB_TYPE_NAME GstVorbisDec
50 static inline guint8 *
51 gst_ogg_packet_data (ogg_packet * p)
53 return (guint8 *) p->packet;
57 gst_ogg_packet_size (ogg_packet * p)
63 gst_ogg_packet_wrapper_from_buffer (ogg_packet * packet, GstBuffer * buffer)
65 packet->packet = GST_BUFFER_DATA (buffer);
66 packet->bytes = GST_BUFFER_SIZE (buffer);
69 static inline ogg_packet *
70 gst_ogg_packet_from_wrapper (ogg_packet_wrapper * packet)
78 #include <Tremolo/ivorbiscodec.h>
79 #include <Tremolo/codec_internal.h>
80 typedef ogg_int16_t vorbis_sample_t;
82 #include <tremor/ivorbiscodec.h>
83 typedef ogg_int32_t vorbis_sample_t;
86 typedef struct _ogg_packet_wrapper ogg_packet_wrapper;
88 struct _ogg_packet_wrapper {
94 #define GST_VORBIS_DEC_DESCRIPTION "decode raw vorbis streams to integer audio"
96 #define GST_VORBIS_DEC_SRC_CAPS \
97 GST_STATIC_CAPS ("audio/x-raw-int, " \
98 "rate = (int) [ 1, MAX ], " \
99 "channels = (int) [ 1, 6 ], " \
100 "endianness = (int) BYTE_ORDER, " \
101 "width = (int) { 16, 32 }, " \
102 "depth = (int) 16, " \
103 "signed = (boolean) true")
105 #define GST_VORBIS_DEC_DEFAULT_SAMPLE_WIDTH (16)
107 /* we need a different type name here */
108 #define GST_VORBIS_DEC_GLIB_TYPE_NAME GstIVorbisDec
110 /* and still have it compile */
111 typedef struct _GstVorbisDec GstIVorbisDec;
112 typedef struct _GstVorbisDecClass GstIVorbisDecClass;
114 /* compensate minor variation */
115 #define vorbis_synthesis(a, b) vorbis_synthesis (a, b, 1)
117 static inline guint8 *
118 gst_ogg_packet_data (ogg_packet * p)
120 return (guint8 *) p->packet->buffer->data;
124 gst_ogg_packet_size (ogg_packet * p)
126 return p->packet->buffer->size;
130 gst_ogg_packet_wrapper_from_buffer (ogg_packet_wrapper * packet,
133 ogg_reference *ref = &packet->ref;
134 ogg_buffer *buf = &packet->buf;
136 buf->data = GST_BUFFER_DATA (buffer);
137 buf->size = GST_BUFFER_SIZE (buffer);
139 buf->ptr.owner = NULL;
140 buf->ptr.next = NULL;
144 ref->length = buf->size;
147 packet->packet.packet = ref;
148 packet->packet.bytes = ref->length;
151 static inline ogg_packet *
152 gst_ogg_packet_from_wrapper (ogg_packet_wrapper * packet)
154 return &(packet->packet);
159 typedef void (*CopySampleFunc)(vorbis_sample_t *out, vorbis_sample_t **in,
160 guint samples, gint channels, gint width);
162 CopySampleFunc get_copy_sample_func (gint channels, gint width);
164 #endif /* __GST_VORBIS_DEC_LIB_H__ */