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., 51 Franklin St, Fifth Floor,
22 * Boston, MA 02110-1301, USA.
25 #ifndef __GST_VORBIS_DEC_LIB_H__
26 #define __GST_VORBIS_DEC_LIB_H__
29 #include <gst/audio/audio.h>
33 #define GST_VORBIS_DEC_DESCRIPTION "decode raw vorbis streams to float audio"
35 #define GST_VORBIS_AUDIO_FORMAT GST_AUDIO_FORMAT_F32
36 #define GST_VORBIS_AUDIO_FORMAT_STR GST_AUDIO_NE (F32)
38 #define GST_VORBIS_DEC_SRC_CAPS \
39 GST_STATIC_CAPS ("audio/x-raw, " \
40 "format = (string)" GST_VORBIS_AUDIO_FORMAT_STR ", " \
41 "rate = (int) [ 1, MAX ], " \
42 "channels = (int) [ 1, 256 ]")
44 #define GST_VORBIS_DEC_DEFAULT_SAMPLE_WIDTH (32)
48 #define GST_VORBIS_DEC_DESCRIPTION "decode raw vorbis streams to integer audio"
50 #define GST_VORBIS_AUDIO_FORMAT GST_AUDIO_FORMAT_S16
51 #define GST_VORBIS_AUDIO_FORMAT_STR GST_AUDIO_NE (S16)
53 #define GST_VORBIS_DEC_SRC_CAPS \
54 GST_STATIC_CAPS ("audio/x-raw, " \
55 "format = (string) " GST_VORBIS_AUDIO_FORMAT_STR ", " \
56 "rate = (int) [ 1, MAX ], " \
57 "channels = (int) [ 1, 6 ]")
59 #define GST_VORBIS_DEC_DEFAULT_SAMPLE_WIDTH (16)
61 /* we need a different type name here */
62 #define GstVorbisDec GstIVorbisDec
63 #define GstVorbisDecClass GstIVorbisDecClass
64 #define gst_vorbis_dec_get_type gst_ivorbis_dec_get_type
65 #define gst_vorbis_get_copy_sample_func gst_ivorbis_get_copy_sample_func
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_map (ogg_packet * packet, GstBuffer * buffer, GstMapInfo *map)
96 gst_buffer_ref (buffer);
97 gst_buffer_map (buffer, map, GST_MAP_READ);
98 packet->packet = map->data;
99 packet->bytes = map->size;
103 gst_ogg_packet_wrapper_unmap (ogg_packet * packet, GstBuffer * buffer, GstMapInfo *map)
105 gst_buffer_unmap (buffer, map);
106 gst_buffer_unref (buffer);
109 static inline ogg_packet *
110 gst_ogg_packet_from_wrapper (ogg_packet_wrapper * packet)
115 #else /* USE_TREMOLO */
117 #include <Tremolo/ivorbiscodec.h>
118 #include <Tremolo/codec_internal.h>
119 typedef ogg_int16_t vorbis_sample_t;
120 typedef struct _ogg_packet_wrapper ogg_packet_wrapper;
122 struct _ogg_packet_wrapper {
128 /* compensate minor variation */
129 #define vorbis_synthesis(a, b) vorbis_synthesis (a, b, 1)
131 static inline guint8 *
132 gst_ogg_packet_data (ogg_packet * p)
134 return (guint8 *) p->packet->buffer->data;
138 gst_ogg_packet_size (ogg_packet * p)
140 return p->packet->buffer->size;
144 gst_ogg_packet_wrapper_map (ogg_packet_wrapper * packet,
145 GstBuffer * buffer, GstMapInfo * map)
148 ogg_reference *ref = &packet->ref;
149 ogg_buffer *buf = &packet->buf;
152 gst_buffer_ref (buffer);
153 gst_buffer_map (buffer, map, GST_MAP_READ);
154 buf->data = map->data;
155 buf->size = map->size;
157 buf->ptr.owner = NULL;
158 buf->ptr.next = NULL;
162 ref->length = buf->size;
165 packet->packet.packet = ref;
166 packet->packet.bytes = ref->length;
170 gst_ogg_packet_wrapper_unmap (ogg_packet_wrapper * packet,
171 GstBuffer * buffer, GstMapInfo * map)
173 ogg_reference *ref = &packet->ref;
174 ogg_buffer *buf = &packet->buf;
176 gst_buffer_unmap (buffer, map);
177 gst_buffer_unref (buffer);
180 static inline ogg_packet *
181 gst_ogg_packet_from_wrapper (ogg_packet_wrapper * packet)
183 return &(packet->packet);
186 #endif /* USE_TREMOLO */
188 typedef void (*CopySampleFunc)(vorbis_sample_t *out, vorbis_sample_t **in,
189 guint samples, gint channels);
191 CopySampleFunc gst_vorbis_get_copy_sample_func (gint channels);
193 #endif /* __GST_VORBIS_DEC_LIB_H__ */