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 #define GST_VORBIS_DEC_DESCRIPTION "decode raw vorbis streams to float audio"
34 #define GST_VORBIS_DEC_SRC_CAPS \
35 GST_STATIC_CAPS ("audio/x-raw-float, " \
36 "rate = (int) [ 1, MAX ], " \
37 "channels = (int) [ 1, 256 ], " \
38 "endianness = (int) BYTE_ORDER, " \
41 #define GST_VORBIS_DEC_DEFAULT_SAMPLE_WIDTH (32)
43 #define GST_VORBIS_DEC_GLIB_TYPE_NAME GstVorbisDec
47 #define GST_VORBIS_DEC_DESCRIPTION "decode raw vorbis streams to integer audio"
49 #define GST_VORBIS_DEC_SRC_CAPS \
50 GST_STATIC_CAPS ("audio/x-raw-int, " \
51 "rate = (int) [ 1, MAX ], " \
52 "channels = (int) [ 1, 6 ], " \
53 "endianness = (int) BYTE_ORDER, " \
54 "width = (int) { 16, 32 }, " \
55 "depth = (int) 16, " \
56 "signed = (boolean) true")
58 #define GST_VORBIS_DEC_DEFAULT_SAMPLE_WIDTH (16)
60 /* we need a different type name here */
61 #define GST_VORBIS_DEC_GLIB_TYPE_NAME GstIVorbisDec
63 /* and still have it compile */
64 typedef struct _GstVorbisDec GstIVorbisDec;
65 typedef struct _GstVorbisDecClass GstIVorbisDecClass;
72 #include <tremor/ivorbiscodec.h>
73 typedef ogg_int32_t vorbis_sample_t;
75 #include <vorbis/codec.h>
76 typedef float vorbis_sample_t;
79 typedef ogg_packet ogg_packet_wrapper;
81 static inline guint8 *
82 gst_ogg_packet_data (ogg_packet * p)
84 return (guint8 *) p->packet;
88 gst_ogg_packet_size (ogg_packet * p)
94 gst_ogg_packet_wrapper_from_buffer (ogg_packet * packet, GstBuffer * buffer)
96 packet->packet = GST_BUFFER_DATA (buffer);
97 packet->bytes = GST_BUFFER_SIZE (buffer);
100 static inline ogg_packet *
101 gst_ogg_packet_from_wrapper (ogg_packet_wrapper * packet)
106 #else /* USE_TREMOLO */
108 #include <Tremolo/ivorbiscodec.h>
109 #include <Tremolo/codec_internal.h>
110 typedef ogg_int16_t vorbis_sample_t;
111 typedef struct _ogg_packet_wrapper ogg_packet_wrapper;
113 struct _ogg_packet_wrapper {
119 /* compensate minor variation */
120 #define vorbis_synthesis(a, b) vorbis_synthesis (a, b, 1)
122 static inline guint8 *
123 gst_ogg_packet_data (ogg_packet * p)
125 return (guint8 *) p->packet->buffer->data;
129 gst_ogg_packet_size (ogg_packet * p)
131 return p->packet->buffer->size;
135 gst_ogg_packet_wrapper_from_buffer (ogg_packet_wrapper * packet,
138 ogg_reference *ref = &packet->ref;
139 ogg_buffer *buf = &packet->buf;
141 buf->data = GST_BUFFER_DATA (buffer);
142 buf->size = GST_BUFFER_SIZE (buffer);
144 buf->ptr.owner = NULL;
145 buf->ptr.next = NULL;
149 ref->length = buf->size;
152 packet->packet.packet = ref;
153 packet->packet.bytes = ref->length;
156 static inline ogg_packet *
157 gst_ogg_packet_from_wrapper (ogg_packet_wrapper * packet)
159 return &(packet->packet);
162 #endif /* USE_TREMOLO */
164 typedef void (*CopySampleFunc)(vorbis_sample_t *out, vorbis_sample_t **in,
165 guint samples, gint channels, gint width);
167 CopySampleFunc get_copy_sample_func (gint channels, gint width);
169 #endif /* __GST_VORBIS_DEC_LIB_H__ */